1

Is there any way to make the centered point to move whilst dragging the map? It seems currently its not possible to add graphics nor remove them whilst dragging happens.

require([
    "esri/Map",
  "esri/views/MapView",
  "esri/Graphic",
  "esri/core/watchUtils",
  "dojo/domReady!"
], function(
    Map,
  MapView,
  Graphic,
  watchUtils
){
    var map = new Map({
    basemap: "hybrid"
  });

  var view = new MapView({
    container: "map",
    map: map,
    constraints: {
        rotationEnabled:false
    }
  });

  var addPoint = function(point){
    view.graphics.removeAll();
    var graphicPoint = {
        type: "point",
      latitude: point.latitude,
      longitude: point.longitude
    };

    var markerSymbol = {
        type: "simple-marker",
      color: [85,139,197],
      outline: {
        color: [255,255,255],
        width:2
      }
    };

    var pointGraphic = new Graphic({
        geometry: graphicPoint,
      symbol: markerSymbol
    });

    view.graphics.add(pointGraphic);
  };

  var centerPoint = function(){
    var point = view.center;
    var input = document.getElementById("myInput");
    input.value = point.latitude.toFixed(5) + " " + point.longitude.toFixed(5);
    addPoint(point);
  };

  var showCenterCoords = function(){
    centerPoint();
    view.on("pointer-move", function(e){
        centerPoint();
    });
  };

  view.when(function(){
    showCenterCoords();
  });
});

https://jsfiddle.net/wrtqn2e3/3/

Im using Esri Js API 4.8.

If you look at the INPUT window, you can see that the "pointer-move" event triggers, because coordinates do refresh even on dragging.

Is there a possible workaround for this to happen?

Thanks in advance.

CodeBox
  • 111
  • 4
  • So you want the center point graphic to move as you pan the map (staying in the center of the map frame)? I'm not sure if that can be done, I think that drawing the map takes precedence over drawing any graphics but I could be wrong. If you add a console.log directly under the graphics.removeAll() and graphics.add() you can see that these methods are firing as you pan, it's just that the map view is not updating. – BigGerman Sep 25 '18 at 19:24
  • @BigGerman Yes, that was my intention. I also noticed the same thing trough various tests yesterday. I was hoping for some alternative maybe, like for example a canvas object that is positioned in the middle, only the minus is that the object itself which will block any map interaction in the place it is positioned. That's why the question for the ticket is for any workarounds to make this happen if possible. – CodeBox Sep 26 '18 at 05:52
  • ESRI actually does this with their ["Geopoint" question widget](http://doc.arcgis.com/en/survey123/desktop/create-surveys/geopoints.htm) for Survey123. It has a pin in the center of the map and lets the user pan to place the pin, the pin stays visible in the center the entire time while pinning. I'm not sure if they do this with out-of-the-box ESRI JS API or with some custom code, or if it is just a canvas object as you suggested. I would try asking this same question on the ESRI Geonet forums under the JS API community, you may get a response from ESRI personal – BigGerman Sep 26 '18 at 15:22

0 Answers0