Hi, I want to know hod can I edit a point on a map clicking on the point then dragging it, and also updating the coordinates of the point. Below is my code, where I create a point using the saved coordinates.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>ArcGIS JavaScript Tutorials: Display point, line, and polygon graphics</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.14/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/layers/GraphicsLayer"
], function(Map, MapView, Graphic, GraphicsLayer) {
var map = new Map({
basemap: "topo-vector"
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [28.159843448357865, -26.374449292814024],
zoom: 13
});
var graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
// Create a point
var point = {
type: "point",
longitude: 28.159843448357865,
latitude: -26.374449292814024
};
var simpleMarkerSymbol = {
type: "simple-marker",
color: [226, 119, 40], // orange
size: 30,
style: "triangle", // default is a circle
outline: {
color: [255, 255, 255], // white
width: 2
}
};
var pointGraphic = new Graphic({
geometry: point,
symbol: simpleMarkerSymbol
});
graphicsLayer.add(pointGraphic);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
Solved! Go to Solution.
Your first example is just a simple Object and does not have a getLatitude method, so yes you have to actually create a new Point as in your second example except like this instead.
var point = new Point({
longitude: 28.159843448357865, latitude: -26.374449292814024
});
Thank you very much Robert