AnsweredAssumed Answered

Get coordinates of a moveable marker symbol

Question asked by Toolman101 on Dec 16, 2015
Latest reply on Dec 16, 2015 by processing...



I'm new to using the ArcGIS javascript api.  I have a map where the user can drag a simple marker symbol to some location.  The symbol is initially loaded centered on a default set of coordinates.  The user then drags the symbol to a new location.  I need to find the new center coordinates (lat & lon) of the symbol once the user releases the mouse button (not the mapPoint where the cursor is located.  This is not always the same as the center of the marker symbol).  If anyone can point me in the right direction, I would greatly appreciate it.  Code I have so far is below, including some of the stuff I was trying without success.


<!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">


    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Create Map Display Mouse Coordinates</title>
    <link rel="stylesheet" href="">


    <script src=""></script>
      var map;




      ], function(
        Map, Edit, webMercatorUtils, Point, SpatialReference, SimpleMarkerSymbol, Color, Graphic, dom
      ) {
        map = new Map("map", {
          basemap: "streets",
          center: [-97.937, 39.487],
          zoom: 4 });


  editToolbar = new Edit(map);


  point = new Point(-97.937, 39.487, new SpatialReference({wkid:4326}));
  markerSymbol = new SimpleMarkerSymbol();
  pointGraphic = new Graphic(point, markerSymbol);

        map.on("load", function()
  {"graphic-add", function()
          { editToolbar.activate(Edit.MOVE, pointGraphic); });//activate edit toolbar on graphic load;
          //after map loads, connect to listen to mouse move & drag events
"mouse-up", showCoordinates);

        function showCoordinates(evt) {
          //the map is in web mercator but display coordinates in geographic (lat, long)
          var mp = webMercatorUtils.webMercatorToGeographic(evt.mapPoint); //cursor location
    //var mp = webMercatorUtils.webMercatorToGeographic(pointGraphic.location); //didn't work
    var symLat = point.getLatitude(); //doesn't change
          //display mouse coordinates
          dom.byId("info").innerHTML = mp.x.toFixed(3) + ", " + mp.y.toFixed(3) + ", " + symLat;
    <div id="map" style="position:relative; width:900px; height:600px; border:1px solid #000;">
      <span id="info" style="position:absolute; left:15px; bottom:5px; color:#000; z-index:50;"></span>