graphics Multiple clicks will cause errors
Uncaught TypeError: Object.defineProperty called on non-object
ok thank you !
sometimes this happens,I don't know if it is caused by different versions ,I also use new version
I am unable to create the exact your use case, but tried with point creation.
Popup is coming with exact latitude and longitude for each point I have clicked.
Screen shot enclosed.
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <title>Draw polyline | Sample | ArcGIS API for JavaScript 4.24</title> <link rel="stylesheet" href="https://js.arcgis.com/4.24/esri/themes/light/main.css" /> <script src="https://js.arcgis.com/4.24/"></script> <style> html, body, #viewDiv { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script> require([ "esri/Map", "esri/views/MapView", "esri/views/draw/Draw", "esri/Graphic", "esri/views/draw/PointDrawAction", "esri/widgets/Popup", ], (Map, MapView, Draw, Graphic, PointDrawAction, Popup) => { const map = new Map({ basemap: "gray-vector", }); const view = new MapView({ container: "viewDiv", map: map, zoom: 15, center: [75, 14], }); view.ui.add("point-button", "top-left"); const draw = new Draw({ view: view, }); document.getElementById("point-button").onclick = () => { const action = draw.create("point"); view.focus(); action.on(["draw-complete"], updateVertices); }; function updateVertices(event) { if (event.coordinates.length > 1) { const result = createGraphic(event); } } function createGraphic(event) { let point = { type: "point", x: event.coordinates[0], y: event.coordinates[1], spatialReference: view.spatialReference, }; let graphic = new Graphic({ geometry: point, symbol: { type: "simple-marker", style: "circle", color: "red", size: "16px", outline: { color: [255, 255, 0], width: 3, }, }, }); view.graphics.add(graphic); showPopup(graphic); } function showPopup(graphic) { console.log( graphic.geometry.latitude + " - " + graphic.geometry.longitude ); view.popup.open({ location: graphic.geometry, content: `<b>latitude: ${graphic.geometry.latitude} <br/> latitude: ${graphic.geometry.longitude}<b>`, }); } }); </script> </head> <body> <div id="viewDiv"> <div id="point-button" class="esri-widget esri-widget--button esri-interactive" title="Draw Point" > <span class="esri-icon-map-pin"></span> </div> </div> </body> </html>
Hi thanks
code
Is it possible to share the code. It will be easy to understand
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.