Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to consume the Esri Drive times geoprocessing service within a Flex application, based around the v2.2 Flex API.

I have seen the sample on how to do this.
- However, mine is a bit more based on ActionScript over MXML.
- I should also point out that I am fairly new to Flex/Esri API development, so lamens terms would be great :)

My application seems to be hitting the GP service ok, and I think I am getting the features returned from the Esri servers, however I am having some difficulty setting up a renderer for the results: enter image description here

I get these 'call to a possible undefined method' a fair bit, but not too sure on how I can tweak this to work.

I have been following the samples provided for symbolising graphics with renderers.

If it helps, I have recorded a short screencast to show the rest of my code.

---EDIT-----
I am getting the features returned to me from the gp service, and I have tried to mimic the Esri Flex sample for drive times, but the graphics are not rendering.

  • Here is a new screencast to give you more details.
  • Here is the code in a text file.
  • i have added a small bounty. Winner will be one who helps spot what ive done wrong and gets my results to render in graphics layer (let me know if you need more info).
  • bonus points on suggestion to streamline the code.

---EDIT2--- Been investigating the requests/responses made from my app and the Esri sample. (links have more info)

So, looking at the response, im getting it in WKID 4326, when it should be 102100.
Im now using the same basemap as the Esri Sample.
I have also hard-coded the output spatial reference to be 102100.
Still no joy.

My App GET request:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons/execute?f=json&Drive%5FTimes=1%202%203&Input%5FLocation=%7B%22features%22%3A%5B%7B%22geometry%22%3A%7B%22x%22%3A%2D13629847%2E781785995%2C%22y%22%3A4548460%2E945559423%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%7D%7D%7D%5D%7D

Esri Sample GET request:

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Network/ESRI_DriveTime_US/GPServer/CreateDriveTimePolygons/execute?f=json&env%3AoutSR=102100&Input%5FLocation=%7B%22features%22%3A%5B%7B%22geometry%22%3A%7B%22x%22%3A%2D10608048%2E003182963%2C%22y%22%3A4721388%2E810494098%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%7D%7D%7D%5D%7D&Drive%5FTimes=1%202%203

share|improve this question
    
+1 for the screen cast - if only I knew Flash.... –  Mapperz Jul 19 '11 at 15:37
2  
Jing is the best tool ever. techsmith.com/jing I should add this to that Q about GIS tools. Saves so much time trying to explain to people about problems or situations. –  Simon Jul 19 '11 at 22:34
    
Nice Simon! +1 for the Jing link. I'll be taking a closer look at that one. –  Dano Jul 21 '11 at 21:09
    
I am curious as to what fix you had to make. –  dkroy Jul 25 '11 at 15:38

6 Answers 6

up vote 1 down vote accepted
+50

The original question is about the class renderer, but it seems like the (initial) issue might be related to the projection of the graphics. To verify this, try it without renderers - it should default to black symbols. If this isn't working, it is probably an issue with the graphics, most likely their projection.

As for the projection, what's the projection of your Map? The key is to have the graphics match the maps projection. There is no automatic projection by the map component. The easiest way to get back the features in the proper map projection from a GP service is something like:

geoprocessTask.outSpatialReference = myMap.spatialReference;

Once you have the features drawn and to get the renderer to work, make sure you're rendering based on an attribute that the features have, and that the attribute values are what you expect. (Looking at the REST request and/or Flash Builder debugging would probably be the easiest way for this).

REST debug tip - when looking at the REST requests: change from f=json or f=amf to f=html. This will allow you to easily see the input parameters as well as trying different combinations. For example, using the "My App GET request:" in your EDIT2, change from f=json to f=html and you will notice that the outSpatialReference is not set.

share|improve this answer
    
Thanks everyone. I spent a lot of the weekend with my head in the code and ur answers really helped. The issue stemmed to be around the spatial reference not being pulled through correctly from the map and also browser cache not helping either. –  Simon Jul 25 '11 at 4:40

You seem to be missing an import:

import com.esri.ags.renderers.supportClasses.UniqueValueInfo

share|improve this answer
    
Thats made the errors go away. Thanks! However, still not getting anything rendering in the graphics layer. Any ideas on what could be missing? –  Simon Jul 19 '11 at 22:36

You forgot a semicolon after:
gp.outSpatialReference = _map.spatialReference and gp.useAMF = false

That is all I see so far. You probably know this already but you can use trace to print values to Flash Builder's Console.

Example: trace("Hello World!");

If you didn't already know that I hope that helps, and if you did I hope this tip helps someone else.

share|improve this answer
    
good point. Added that, but still no change. ty –  Simon Jul 22 '11 at 2:17
    
I have been putting breakpoints in the code and stepping through it and comparing it to Esri sample. I can't see why mine is not rendering the graphics, cos its def getting them. –  Simon Jul 23 '11 at 3:21
    
I think you have your graphics trying to display in the wrong projection. I had a similar problem earlier. –  dkroy Jul 24 '11 at 8:49

did you try to refresh your graphic layer after the results func?

in case of results:

function onResult(
gpResult:ExecuteResult,
token:Object = null):void
{
var pv:ParameterValue = gpResult.results[0];
var fs:FeatureSet = pv.value as FeatureSet;
graphicsLayer.graphicProvider = fs.features;
graphicsLayer.refresh();
}

Good luck :-)

share|improve this answer
    
Again another good suggestion, but no cigar (still doesnt display results). It will likely be something small like this. –  Simon Jul 23 '11 at 0:07

Instead of altering the request to change it from the geometric projection to Web Mercator use geographicToWebMercator(Geometry) for the geometries that are returned.

That would be the suggested way instead of hard-coding the request. Let me know how this works. I have had this same issue with the routing API earlier and once I did this conversion before adding it to the Graphics Layer I did this conversion and since it was in the correct projection the Graphics were correctly displayed.

share|improve this answer

Flex / Flash Error #1180 Fix:

Make sure that when you instantiate the Object that you are using the Class name and not the variable name.

Bad Code:

var myCustomClass:CustomClass = new myCustomClass();

Good Code:

var myCustomClass:CustomClass = new CustomClass();

Another example of getting this “error” is by forgetting the keyword “public” in front of the class declaration;

class class_name
{
//Not public
}
public class class_name
{
//Public
}

source: http://curtismorley.com/2008/08/25/flash-error-1180-call-to-a-possibly-undefined-method-mycustomclass/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.