I need to check for coincident points being returned from a FindTask, in order to zoom to the proper extent. I am currently zooming using a centerAndZoom for single points, and using a setExtent for lines, polygons and multiple points. But this will not work properly if the results set is a pair of coincident points, for example. Below is a sample of my current zoom code, but I need a solution for this coincident point scenario.
Anyone solved this kind of problem?
Thanks!
if (graphictype == "point" && map.graphics.graphics.length == 1) {
map.centerAndZoom(map.graphics.graphics[0].geometry,20);
}
else {
var extent = esri.graphicsExtent(map.graphics.graphics);
map.setExtent(extent.expand(2), true);
}
Solved! Go to Solution.
Peggy,
Try something like this:
if (graphictype == "point" && map.graphics.graphics.length == 1) { map.centerAndZoom(map.graphics.graphics[0].geometry,20); } else if (graphictype == "point" && map.graphics.graphics.length > 1 && !esri.graphicsExtent(map.graphics.graphics)){ map.centerAndZoom(map.graphics.graphics[0].geometry,20); } else { var extent = esri.graphicsExtent(map.graphics.graphics); map.setExtent(extent.expand(2), true); }
Peggy,
So does the coincident points produce an extent using graphicsExtent? if they do then you can check the width of the extent and if it does not return a predetermined size then fallback to using centerAndZoom. If the coincident points do not produce an extent using graphicsExtent then same thing fallback to centerAndZoom.
Thanks for the suggestions Robert.
No, the coincident points do not produce and extent using graphicsExtent.
I know how to use centerAndZoom to zoom to 1 graphic. But how do I use it to zoom to multiples?
OR
How do I check for coincidence?
Thanks!
Peggy,
Try something like this:
if (graphictype == "point" && map.graphics.graphics.length == 1) { map.centerAndZoom(map.graphics.graphics[0].geometry,20); } else if (graphictype == "point" && map.graphics.graphics.length > 1 && !esri.graphicsExtent(map.graphics.graphics)){ map.centerAndZoom(map.graphics.graphics[0].geometry,20); } else { var extent = esri.graphicsExtent(map.graphics.graphics); map.setExtent(extent.expand(2), true); }
Robert,
Thanks... that worked perfectly!