Esri / storymap-shortlist

The Shortlist story map application template by Esri
http://storymaps.arcgis.com/en/app-list/shortlist/
Apache License 2.0
43 stars 61 forks source link

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

Open cblandy opened 8 years ago

cblandy commented 8 years ago

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 commented 8 years ago

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