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