Select to view content in your preferred language

centerAndZoom Issue

1241
11
Jump to solution
11-02-2012 06:16 AM
by Anonymous User
Not applicable
when using centerAndZoom, the point is centered left-right (East-West) but shifted Down (South) from the center of screen. Has anyone else seen this? This behavior is experienced in both PC as well as mobile device.

function doTheZoom(geom) {
   map.centerAndZoom(geom,16);
}



Thanks!

RGibson
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
So apparently the issue was with how the sample uses the resizeMap function and the CSS. The fix was to subtract the height of the header from the screen height, like so:

$('#map').css("height", (screen.height - (document.getElementById("header").height)));

RGibson

View solution in original post

0 Kudos
11 Replies
AndyBurns
Regular Contributor
Hi

What's on your geom parameter?

Try setting your geom with a wkid (matching the basemap)...something like this:

                    var point = new esri.geometry.Point([x, y], new esri.SpatialReference({
                        wkid: 27700
                    }));
                    console.log("Zooming to location...", point, zoomLevel);
                    map.centerAndZoom(point, zoomLevel);
                    console.log("Zoom complete");
0 Kudos
by Anonymous User
Not applicable
The geometry is actually the location of a returned address location.....

function showResults(candidates) {
var candidate = candidates[0];
..............

geom = candidate.location; 

Thanks!!
0 Kudos
by Anonymous User
Not applicable
I may need to clarify the issue. The geom is in the correct location on the map. However the location on the map isn't centered on the screen as it should be. It's shifted down or to the South.

r
0 Kudos
AndyBurns
Regular Contributor
okay got it.

Are the returned co ords and the basemap in the same spatial ref?

try creating a point for it to go to

ie:

function showResults(candidates) {
var candidate = candidates[0];
..............

 geom = candidate.location; 

 var point = new esri.geometry.Point([geom], new esri.SpatialReference({
                        wkid: YOUR WKID
                    }));

 map.centerAndZoom(point, 16);


If you can output the results of your geom i will check to ensure everything is there.

I had similar issues and it was down to not specifying the spatial ref or the spatial ref of the basemap was incorrect with the spatial ref of the address results, you might need to run a geometry job to change spatial ref but if you can let me know your basemap spatial ref and the address locator spatial ref that will clear that up.

cheers
0 Kudos
by Anonymous User
Not applicable
The original coords of the address location is a state plane (3433) and the basemap is 102100 (World Street Map from AGS Online). I've done this before and not experienced this issue. Only with this app am I having the issue.

r
0 Kudos
AndyBurns
Regular Contributor
Hi

Okay, try the geometry reproject service here - http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project

see if the results when you reproject to 102100 are better suited try testing with these new co ords hard coded just to see if its where it should be, thats the only thing i can think of that there is a mismatched between the spatial ref's

inSR = 3443
outSR = 102100

Geometries X, Y

Sorry i cant be of anymore help.
0 Kudos
by Anonymous User
Not applicable
Thanks for your assistance, Andy. The point is falling where it should geographically speaking. The issue is essentially one of screen shift.

RGibson
0 Kudos
by Anonymous User
Not applicable
Looks like even the Mobile - Geolocation Sample has this issue.....hmmmm.
0 Kudos
AndyBurns
Regular Contributor
wierd, i guess that you tried that on your local machine...


Can you try the html5 one aswell and see if you get similar results?

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/exp_geolocate.html
0 Kudos