1

My graphicGemetry object contains X and Y values (-9212442.86532579,4421916.145327024) but my image isn't appearing. I suspect there are other data values I need in order to plot my point but I do not know what they are.

Here is what I have and no errors are being reported:

cppr.App.map.graphics.clear();
var symbol = new esri.symbol.SimpleMarkerSymbol(
esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 
18, // symbol size
new esri.symbol.SimpleLineSymbol(
    esri.symbol.SimpleLineSymbol.STYLE_SOLID,   
    new dojo.Color([0,0,0]),
    1),
    new dojo.Color([255,255,0,0.80])
);  
cppr.App.map.graphics.add(new esri.Graphic(graphicGeometry, symbol));

I should also add that I've used this code above when I queried the map service. What I'm doing now is querying a MSSQL Database to pull back the name. the database also contains the x & y coordindates so I thought I'd be able to reuse the same code as shown above but apparently there is something missing.

  • to further explain what I mean, when I console.log on my existing page, my geometry object has numerous key value pars, and some even have sub-objects. On this new page where I'm just passing the x and y, the x and y key value pair is all I see in the console.log. – HPWD Feb 28 '14 at 22:25
  • Have you set the spatial reference for the geometry object? If not it defaults to 4326, which is not valid for your coordinates (-9212442.86532579,4421916.145327024). – evv_gis Feb 28 '14 at 22:33
  • Yes, I'm using 102100. Well, kind of. I manually added it to my geometry object. – HPWD Feb 28 '14 at 23:06
  • cl.ly/image/2L2g3l2U2h1T here is what the console.log shows... – HPWD Feb 28 '14 at 23:09
2

Rather than manually adding it to your object, set the spatial reference like so:

    graphicGeometry.setSpatialReference(new esri.SpatialReference(102100));
0

Have you added esri.symbol.SimpleMarkerSymbol, SimpleLineSymbol and any others to your require line to ensure it's loaded? Being modular, you need to include the individual namespaces your app will use.

Also it might be worth using the debugger to inspect your symbol. Put the debugger; keyword on the line after your symbol is created and check it's actually created something successfully.

  • I am very new to this - not sure what you this "debugger" is that you speak of. Can you elaborate or provide a link? – HPWD Mar 3 '14 at 15:27
  • No worries - if you put the JavaScript keyword 'debbuger' on a line and are using a browser with development tools (such as IE with the F12 dev tools open, Chrome, Firefox, Firefox with Firebug - there are plenty to choose from) then the debugger command acts as a breakpoint. This pauses the script and allows you to then inspect the properties of objects and so on. Here is a related post: stackoverflow.com/questions/66420/… – Kate Mar 3 '14 at 18:11
  • Ah yeah, i've use that but not in the instance. I thought you meant something specific with ArcGIS. Thanks for the link, it was a good reminder. – HPWD Mar 7 '14 at 4:05
  • I did have the require set up. Turns out, my spatial references didn't match. – HPWD Mar 7 '14 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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