3

I have an ArcGIS JavaScript map that I'm trying to use with a Query Task. The query runs fine on the server side and the proper geometry is returned. Then, I draw the feature as follows:

var features = featureSet.features;
for (var i = 0; i < features.length; i++) {
 var feature = features[i];
 feature.setSymbol(lbSymbol);
 feature.setInfoTemplate(lbInfoTemplate);
 map.graphics.add(feature);
}

This was working for a while but it randomly broke and I can't figure out why. No errors -- the map just doesn't draw anything. If I listen for the graphics-add event on the graphics layer it fires and all the event data looks fine (including spatial reference, geometry, etc.) Can anyone think of why this wouldn't work or how else to troubleshoot?

For what it's worth - this code to zoom to the extent of the feature is also broken:

var extent = esri.graphicsExtent(features);
if (extent) {
 extent = extent.expand(3.0);
 map.setExtent(extent);
}

The extent of esri.graphicsExtent(features) matches the extent of the feature. Not sure why the map doesn't zoom on setExtent.

UPDATE: I noticed that graphics layer is referenced to WGS84, while the map and graphic feature are State Plane. I'm just using the built-in map.graphics layer -- I assumed this would match the spatial reference of the map automatically. Still puzzled.

asked Oct 15, 2013 at 18:53
2
  • are you setting outSpatialReference for the query? does this spatial reference match your map? can you post a link to broken app or write a complete fiddle pointing at a public service? Commented Oct 16, 2013 at 5:16
  • Hi John, I'm not setting outSpatialReference but it matches the map's so I think it's okay. Unfortunately I'm using intranet services so I can't post a working link, but here is a fiddle of the relevant code: jsfiddle.net/panbalanga/Re5AB/5 Commented Oct 16, 2013 at 15:51

1 Answer 1

0

What do you mean "the graphics layer is referenced to WGS84?" The map's graphics layer uses the spatial reference of the map. You have to project the geometry from your query, as John Gravois said.

Is the query task talking to a map service? If so, you should use a feature layer and let it handle the results of your query.

answered Oct 18, 2013 at 5:03
1
  • The graphics layer (map.graphics) has a property called spatialReference with a WKID of 4326 (WGS84). The map uses State Plane. Not sure if the SR of the graphics layer matters, but it's there. The geometry of the query is the same as the map so I didn't think I would need to project. The query task is talking to a map service -- I didn't even think to use a feature layer but that sounds like a good idea. I'll try that next. Thanks! Commented Oct 18, 2013 at 5:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.