Solved! Go to Solution.
It will be a point on layer. The concept is to add water utility service orders to a feature layer by our service technicians (zach). From there it will go back to our server to be processed on ArcMap. We were initially going to have them place it manually with Editor, but we need more accuracy. Any ideas?
Home. Run.
Thank you, Jatin!
<script> var map; var graphic; var currLocation; var watchId; require([ "esri/map", "esri/geometry/Point","esri/layers/FeatureLayer", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/graphic", "esri/Color", "dojo/domReady!" ], function bat( Map, Point,FeatureLayer, SimpleMarkerSymbol, SimpleLineSymbol, Graphic, Color ) { map = new Map("map", { basemap: "oceans", center: [-85.957, 17.140], zoom: 11 }); var featureLayer = new FeatureLayer("", { mode: FeatureLayer.MODE_SELECTION, outFields: ["*"] }); map.addLayer(featureLayer); map.on("load", initFunc); function orientationChanged() { if(map){ map.reposition(); map.resize(); } } function initFunc(map) { if( navigator.geolocation ) { navigator.geolocation.getCurrentPosition(zoomToLocation, locationError); watchId = navigator.geolocation.watchPosition(showLocation, locationError); } else { alert("Browser doesn't support Geolocation. Visit http://caniuse.com to see browser support for the Geolocation API."); } } function locationError(error) { //error occurred so stop watchPosition if( navigator.geolocation ) { navigator.geolocation.clearWatch(watchId); } switch (error.code) { case error.PERMISSION_DENIED: alert("Location not provided"); break; case error.POSITION_UNAVAILABLE: alert("Current location not available"); break; case error.TIMEOUT: alert("Timeout"); break; default: alert("unknown error"); break; } } function zoomToLocation(location) { var pt = new Point(location.coords.longitude, location.coords.latitude); addGraphic(pt); map.centerAndZoom(pt, 12); } function showLocation(location) { //zoom to the users location and add a graphic var pt = new Point(location.coords.longitude, location.coords.latitude); if ( !graphic ) { addGraphic(pt); } else { // move the graphic if it already exists graphic.setGeometry(pt); } map.centerAt(pt); } var geometry; function addGraphic(pt){ var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CIRCLE, 12); graphic = new Graphic(pt, symbol); map.graphics.add(graphic); new esri.geometry.Point(pt, map.spatialReference); var newFeature = new esri.Graphic(geometry, null,null); featureLayer.applyEdits([newFeature], null, null, function () {}, function() {}); } }); </script>
var newFeature = new esri.Graphic(geometry, null,null); featureLayer.applyEdits([graphic], null, null);
var fieldAttributes = {};
fieldAttributes["tech"] = "Zach";
fieldAttributes["MeterNumber"] = 1234;
.
.
.
.
var newFeature = new esri.Graphic(geometry, null, fieldAttributes);
featureLayer.applyEdits([newFeature], null, null, function () {//success}, function() {//error});