Select to view content in your preferred language

Map.graphics.add() not showing points on the map

8466
16
Jump to solution
11-13-2013 10:25 AM
IrfanClemson
Occasional Contributor II
Hi,
I have inherited an ArcGIS JavaScript API project. I am very new to this API in particular and ArcGIS in general. Currently, one part of the code is very problematic--populating the map with some query task's results. Here is a code snippet. In the debugger I can see the returned results, including geometry of individual result rows. But they never show up on the map.

  function showResults(results) {//This bounds the results into the data grid from doFind() function      var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 200), new dojo.Color([98,194,204,0.5]));       for(var i=0; i < results.features.length; i++){        //map.graphics.add(results.features);     var graphic = results.features;     graphic.setSymbol(symbol);     map.graphics.add(graphic);      }              }    


What could be happening? I don't think posting thousands of line of code will help. But the debugger does show information for each row, such as:
map.graphics.graphics.geometry[0]->
- _shape=null
- type=point
- x= 283265
- y= 3955658
- symbol [object data]

and when I go to:
http://myserver/arcgis/rest/services/NPS_Location_Search/MapServer/0
then, under Drawing Info, I can see the colored dot object for Symbol.

I can give more info about how the various maps are laid out if that helps?

Thanks!
Meengla
0 Kudos
16 Replies
IrfanClemson
Occasional Contributor II
what type of geometry are you returning?

Your Subject says "points" but your code is using a fill symbol, which is polygon


In the debug I see the geometry as type of Point.

So I guess I should change the following line?

Thanks!

var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 4), new dojo.Color([98,194,204,0.5]));
0 Kudos
IrfanClemson
Occasional Contributor II
Progress! If I change the symbol to:
var symbol = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SOLID);

then they do show up on the map--although just about half way across the world with seemingly the same latitude and now zooming out doesn NOT show the '_3be' error I mention above...
0 Kudos
IrfanClemson
Occasional Contributor II
symbols are now showing up on their proper location on the map. I had to put in this line of code again (thanks @Odoe!):
query.outSpatialReference = map.spatialReference;

Thank you all very much! I think next I will need to work out zoom map location from a result grid--but that is a different topic.
0 Kudos
JeffPace
MVP Alum
sp it looks like two issues, spatial reference and symbology.

IF they draw the query is good and symbology fixed

Now you just need to specify the correct outSpatialReference in the query parameters, as mentioned above
0 Kudos
JeffPace
MVP Alum
symbols are now showing up on their proper location on the map. I had to put in this line of code again (thanks @Odoe!):
query.outSpatialReference = map.spatialReference;

Thank you all very much! I think next I will need to work out zoom map location from a result grid--but that is a different topic.


great! if you could mark either odoe's or my post as the answer (since we each got half, doesnt matter whom) that would be appreciated (just click the check mark on the right).
0 Kudos
IrfanClemson
Occasional Contributor II
great! if you could mark either odoe's or my post as the answer (since we each got half, doesnt matter whom) that would be appreciated (just click the check mark on the right).


Marked--it was really 50/50 solution between the two of you (Jeff.pace and @Odoe). Without specifying the correct symbol the map wouldn't show the symbol and without inputting the correct spatial info the symbols would show but--in Africa--which I would have missed.

Thank you both again!
0 Kudos
KenBuja
MVP Esteemed Contributor
Marked--it was really 50/50 solution between the two of you (Jeff.pace and @Odoe). Without specifying the correct symbol the map wouldn't show the symbol and without inputting the correct spatial info the symbols would show but--in Africa--which I would have missed.

Thank you both again!


In addition to the marking the post as answered, you should also use the up arrows to show which posts were helpful. This will also reward Jeff's input.
0 Kudos