Select to view content in your preferred language

Inconsistent Map Centering After Geocode Result Returned

2774
4
Jump to solution
10-20-2015 02:46 PM
SethLewis1
Frequent Contributor

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:

slt_center_map.PNG

While other addresses will return the graphic pt in the top left or right of the resulting extent:

slt_offright_map.PNG

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

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Seth,

   It is like a timing issue then. You should be using something like:

map.centerAt(point).then(.....

View solution in original post

4 Replies
AndyGup
Esri Regular Contributor

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().

SethLewis1
Frequent Contributor

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

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Seth,

   It is like a timing issue then. You should be using something like:

map.centerAt(point).then(.....

SethLewis1
Frequent Contributor

Robert,

You were correct. It was a timing issue. Once we adjusted for that the issue was resolved.

Much appreciated!

0 Kudos