if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(location) { gpsPoint.setLatitude(location.coords.latitude); gpsPoint.setLongitude(location.coords.longitude); gpsGraphic.setGeometry(gpsPoint); gpsGraphic.setSymbol(gpsSymbol); map.graphics.add(gpsGraphic); map.centerAndZoom(gpsPoint, 12); gpsIsOn = true; }); }
// Project gpsPoint to State Plane var projectParams = new esri.tasks.ProjectParameters(); projectParams.geometries = [gpsPoint]; projectParams.outSR = map.spatialReference; var defer = geometryService.project(projectParams); dojo.when( defer, function(projectedGeometry) { if (projectedGeometry.length > 0) { gpsPoint = projectedGeometry[0]; } });
Solved! Go to Solution.
project : function(_1e, _1f, _20, _21) { var _22 = _2.mixin({}, this._url.query, { f : "json" }), _23; ...
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(location) { gpsPoint.setLatitude(location.coords.latitude); gpsPoint.setLongitude(location.coords.longitude); projectToMapCoords(gpsPoint); }); } function projectToMapCoords(gpsPoint) { // Project gpsPoint to State Plane var projectParams = new esri.tasks.ProjectParameters(); projectParams.geometries = [gpsPoint]; projectParams.outSR = map.spatialReference; geometryService.project(projectParams, projectCallback); } function projectCallback(projectParams) { var newPoint; if (projectParams.length > 0) { newPoint= projectParams[0]; gpsGraphic.setGeometry(newPoint); gpsGraphic.setSymbol(gpsSymbol); map.graphics.add(gpsGraphic); map.centerAndZoom(newPoint, 12); gpsIsOn = true; } }
project : function(_1e, _1f, _20, _21) { var _22 = _2.mixin({}, this._url.query, { f : "json" }), _23; ...