When the SketchViewModel is active, every time I move the mouse pointer I get the following warning on the browser console:
[esri.geometry.Point] .latitude= Longitude was defined without latitude
The mouse move event is fired very frequently, so after a few seconds you can end up with thousands of warnings. I'd rather get rid of this behavior if possible.
I have noticed that the warnings only appear if you use uncommon spatial references such as 2157 or 26711, while no warnings appear with other more familiar spatial references such as 4326 or 102100. I also noticed that when the warnings appear, the points get proper values for x and y but odd values for latitude and longitude:
latitude: null
longitude: NaN
I'm using the ArcGIS API for JavaScript 4.19. You can find a CodePen here.
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Sketch widget | Sample | ArcGIS API for JavaScript 4.19</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.19/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/GraphicsLayer",
"esri/layers/MapImageLayer",
"esri/widgets/Sketch/SketchViewModel"
], (Map, MapView, GraphicsLayer, MapImageLayer, SketchViewModel) => {
const mapImageLayer = new MapImageLayer({
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/VerticalLines/MapServer"
});
const graphicsLayer = new GraphicsLayer();
const map = new Map({
layers: [mapImageLayer, graphicsLayer]
});
const view = new MapView({
container: "viewDiv",
map: map,
scale: 75000
});
view.when(() => {
const sketch = new SketchViewModel({
layer: graphicsLayer,
view: view,
defaultCreateOptions: { hasZ: false }
});
sketch.create("point");
sketch.on("create", evt => {
if (evt.state === "complete") {
console.log(evt);
}
});
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>