Our app returns a graphic point based on an address search. And we've encountered inconsistent behavior when it comes to the map centering on results.
Some addresses will return the graphic pt placed in the center of the map as intended:
While other addresses will return the graphic pt in the top left or right of the resulting extent:
And other address searches will center the map on an area where the graphic point isn't showing at all (though it's still returned to the map as evidenced by the user zooming out or panning).
After the graphic pt is called we have our zoom function:
function zoomToPlaces(places) { var multiPoint = new Multipoint(map.spatialReference); for (var i = 0; i < places.length; i++) { //multiPoint.addPoint(places.location); multiPoint.addPoint(places.feature.geometry); } map.setExtent(multiPoint.getExtent().expand(2.0)); }
Would having the expand factor set at 2 be a possible cause of this behavior? Has anyone encountered this issue before?
Message was edited by: Seth Lewis
Solved! Go to Solution.
Seth,
It is like a timing issue then. You should be using something like:
map.centerAt(point).then(.....
Seth, I'm not sure what the issue is, however if you have a geometry point you can always force the map to center on it using map.centerAt() or map.centerAndZoom().
Andy,
Thanks for your response. I should've included in my original post that we're calling map.centerAt(pt) earlier in our script but we'll look at centerAndZoom as a workaround if we're unable to determine a cause.
Seth
Seth,
It is like a timing issue then. You should be using something like:
map.centerAt(point).then(.....
Robert,
You were correct. It was a timing issue. Once we adjusted for that the issue was resolved.
Much appreciated!