- Here is what I am trying to do: on click (right now just click anywhere on the map) will draw the line and display a drag-able modal pop-up, I have static coordinates set for the start point (which will later be dynamic), but I would like the second point to find the draggable pop-up modal and stay with it even when it is dragged.
- I started the logic of following the mouse pointer continuously to get the end coordinates. But now thinking not the best method for finding and following modal.
Below is what I have: arcgis-js
require([
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/layers/GraphicsLayer",
"esri/geometry/support/webMercatorUtils",
"dojo/dom",
],
function init (Map, MapView, Graphic, GraphicsLayer, webMercatorUtils, dom) {
var map = new Map({
basemap: "topo-vector"
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [-80.96135253906438, 35.9411934679851],
zoom: 3
});
var graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
// Create a line geometry
var simpleLineSymbol = {
type: "simple-line",
color: [13,121,190, .9],
style: "short-dash",
width: 3
};
function showCoordinates(evt) {
var point = view.toMap({x: evt.x, y: evt.y});
//the map is in web mercator but display coordinates in geographic (lat, long)
var mp = webMercatorUtils.webMercatorToGeographic(point);
//display mouse coordinates
dom.byId("info").innerHTML = mp.x.toFixed(3) + ", " + mp.y.toFixed(3);
const coordinatesAx = -80.96135253906438;
const coordinatesAy = 35.9411934679851;
const coordinatesBx = mp.x.toFixed(3);
const coordinatesBy = mp.y.toFixed(3);
var polyline = {
type: "polyline",
paths: [
[coordinatesAx, coordinatesAy],
[coordinatesBx, coordinatesBy]
]
};
var polylineGraphic = new Graphic({
geometry: polyline,
symbol: simpleLineSymbol
})
//graphicsLayer.add(polylineGraphic);
document.getElementById("viewDiv").onclick = function fun() {
graphicsLayer.add(polylineGraphic);
}
}
view.when(function(){
//after map loads, connect to listen to mouse move & drag events
view.on("pointer-move", showCoordinates);
//graphicsLayer.add(polylineGraphic);
});
});
And for the draggable modal using jQuery Kendo, that I'll call in a separate file (but shouldn't matter how this part is derived just want point B to follow modal/div elem).
<script>
$("#dialog").kendoWindow({
draggable: true
});
</script>
- here is a visual of what I am trying to accomplish. This would
que on click, and the polyline would follow the
draggable modal
...*
Mostly just struggling with getting one point of the line to find, and follow my draggable modal. any ideas how I could accomplish this? on pointer-move
is clearly not the answer at all.