Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geolocator deesn't work if web map (in organizational portal) spatial reference is not Web Mercator #54

Open
cblandy opened this issue Oct 29, 2015 · 1 comment

Comments

@cblandy
Copy link

cblandy commented Oct 29, 2015

I discovered that if your web map has a spatial reference other than Web Mercator that geolocate widget does not work.
While it is not hard to fix (see code below) it should be noted as an issue and rolled into production in the future.

Firstly we need to update _geomServiceUrl (maybe this could set in the index.html like some of the other parameters) to access your GeometryService rest end point.
_geomServiceUrl = new esri.tasks.GeometryService('http://ArcGIS/rest/services/Utilities/Geometry/GeometryServer');
esriConfig.defaults.geometryService = _geomServiceUrl;

Then in the getDeviceLocation function replace (I wish to zoom in and center)
var locationPoint = esri.geometry.geographicToWebMercator(geom);
_map.centerAt(locationPoint);
displayLocationPin(locationPoint);

with
_geomServiceUrl.project([geom], _map.spatialReference, function(projectedPoints) {
var locationPoint = projectedPoints[0];
_map.centerAndZoom(locationPoint, 11); //Assumes tiled based map
//_map.centerAt(locationPoint);
displayLocationPin(locationPoint);
});

Just thought I would post the code for anybody interested.

Cameron

@cooney
Copy link
Contributor

cooney commented Oct 29, 2015

Thanks for pointing this out to us, and providing a solution. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants