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?
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});
var newFeature = new esri.Graphic(geometry, null,null); featureLayer.applyEdits([graphic], null, null);
<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>
Home. Run.Thank you, Jatin!
Your help is very much appreciated, but I have one tiny, little question. How do I tie in the graphic to push the point to the feature layer? function addGraphic(pt){ var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CIRCLE, 12); graphic = new Graphic(pt, symbol); map.graphics.add(graphic); // zach is feature layer map.zach.add(graphic); new esri.geometry.Point(pt, map.spatialReference);Pardon my incompetence, I'm transferring over from Flex.
function addGraphic(pt){ var symbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_CIRCLE, 12); graphic = new Graphic(pt, symbol); map.graphics.add(graphic); // zach is feature layer map.zach.add(graphic); new esri.geometry.Point(pt, map.spatialReference);
Is _manager your feature layer?
function gpsPoint() { navigator.geolocation.getCurrentPosition(function (position) { var pt = esri.geometry.geographicToWebMercator(new esri.geometry.Point(position.coords.longitude, position.coords.latitude)); updateCollectedPoints(pt); }, null, { enableHighAccuracy: true, maximumAge: 0, timeout: 9000 }); }
pointsCollected.push(pt); ///pointscollected is a global varable geometry = new esri.geometry.Polyline(_map.spatialReference); geometry.addPath(pointsCollected); symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color("red"), 5); var graphic = new esri.Graphic(geometry, symbol); graphic.setAttributes({ "drawtype": "collected" }); _map.graphics.add(graphic);
var handlerd, mcpx, mcpy; //declare your variables//add function that will be activated when button clicked function getmappoint() { handlerd = dojo.connect(map, "onClick", getmapcoordinates); map.hideZoomSlider();}function getmapcoordinates(evt){ map.graphics.clear(); var mpoint = new esri.geometry.Point(evt.mapPoint.x, evt.mapPoint.y, map.spatialReference); var msymbol = new esri.symbol.PictureMarkerSymbol({ "angle" : 0, "xoffset" : 6, "yoffset" : 12, "url" : "images/red_pin.png", "width" : 24, "height" : 24 }); var mgraphic = new esri.Graphic(mpoint, msymbol); map.graphics.add(mgraphic); mcpx = evt.mapPoint.getLongitude(); mcpy = evt.mapPoint.getLatitude(); dojo.byId("inLat").value = mcpy.toFixed(8); dojo.byId("inLon").value = mcpx.toFixed(8);}//add button and text boxes for Lat-Long coord<p>Get coordinates by clicking on the button below and then clicking on the map</p><button data-dojo-type="dijit.form.Button" onClick="getmappoint()">Get Coordinates</button><div><span>Latitude: </span><input tabindex="2" type="text" id="inLat" /></div><div><span>Longitude:</span><input tabindex="1" type="text" id="inLon" /></div>
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.