Hi all,
In my code I am trying to buffer a parcel and then highlight the parcels that interesect the buffer. the code works fine for the buffer and add the first graphic on the map. but after performing the query to add the second graphic, it won't work. I am not sure why!
here is my code:
// Listen for GeometryService onBufferComplete event
dojo.connect(gsvc, "onBufferComplete", function(graphics) {
var symbol = new esri.symbol.SimpleFillSymbol("none", new esri.symbol.SimpleLineSymbol("solid", new dojo.Color([255, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]));
var graphic = new esri.Graphic(graphics[0], symbol);
map.graphics.add(graphic); // this one works fine...
query.geometry = graphic.geometry;
query.outSpatialReference = {"wkid":3754};
queryTask.execute(query);
map.setExtent(map.graphics.graphics[0].geometry.getExtent().expand(1.25));
});
// +++++Listen for QueryTask executecomplete event+++++
dojo.connect(queryTask, "onComplete", function(fset) {
dojo.byId('ResultsGoHere').innerHTML = " ";
var resultFeatures = fset.features;
var symbol = new esri.symbol.SimpleFillSymbol(
"solid",
new esri.symbol.SimpleLineSymbol(
"none",
new dojo.Color([0, 0, 255, 0.65]), 2),
new dojo.Color([255, 0, 255, 0.35]));
var noOfPolys = resultFeatures.length;
var graphic2, i;
// run this for loop to highlight the parcels
for (i = 0; i < noOfPolys; i++) {
graphic2 = new esri.Graphic(resultFeatures.geometry, symbol);
map.graphics.add(graphic2); //here no graphics added to the map;
}
}
Solved! Go to Solution.
Richard,
The spatial reference is likely the issue I would be setting it to the maps spatial reference.
Richard,
Do you get to this line of code: dojo.byId('ResultsGoHere').innerHTML = " "; in your onComplete function?
Why are you setting the outSpatialReference like this query.outSpatialReference = {"wkid":3754}; and not setting it to the maps spatial reference?
Thank you Robert for your reply,
Yes, I do get to that line and even go all the way to the bottom and show the results of parcels Ids within the buffer but not highlighting those parcels on the map!
Could that outSpatialReference on a query could be the problem?
Richard,
The spatial reference is likely the issue I would be setting it to the maps spatial reference.
I changed the outspatialReference to map.spatialReference and it's working fine.
Thank you Robert...