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?
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>
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);
Is _manager your 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);
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.