Select to view content in your preferred language

Warnings thrown by SketchViewModel on every mouse move when using uncommon spatial references

2335
9
Jump to solution
06-08-2021 03:19 PM
ljlopez
Occasional Contributor

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>

 

 

1 Solution

Accepted Solutions
JoseBanuelos
Esri Contributor

Hi,

There was a bug logged for this in 4.19 (BUG-000139631), and we are working on getting this resolved for 4.20.

Thanks,
Jose

View solution in original post

9 Replies
Stacy-Rendall
Regular Contributor

I am also seeing this issue

0 Kudos
JoseBanuelos
Esri Contributor

Hi,

There was a bug logged for this in 4.19 (BUG-000139631), and we are working on getting this resolved for 4.20.

Thanks,
Jose

NicoleSulzberger
Regular Contributor

HI @JoseBanuelos 

I still have this issue with 4.20.2 and EPSG:2056 (Swiss projection). Is this a known issue? 

 

0 Kudos
JoseBanuelos
Esri Contributor

Hello @NicoleSulzberger ,
Can you provide an example of a simple reproducible sample? I just tested EPSG:2056 and could not repro. If I revert back to 4.19 I can repro, but at 4.20 I don't see this.

0 Kudos
NicoleSulzberger
Regular Contributor
0 Kudos
JoseBanuelos
Esri Contributor

Hi @NicoleSulzberger ,

I cannot see the warning message from this issue on this sample you provided. I don't see the following warning message

[esri.geometry.Point] .latitude= Longitude was defined without latitude

If you change the version to 4.19, you will be able to see the warning message, but you won't be able to see it at 4.20. Are you still seeing this message? If you are, what browser are you using and what version?

Thanks,

Jose

0 Kudos
NicoleSulzberger
Regular Contributor

Hi @JoseBanuelos 

 I am using Chrome on Windows:


Google Chrome ist auf dem neuesten Stand.
Version 93.0.4577.63 (Offizieller Build) (64-Bit)

 
0 Kudos
JoseBanuelos
Esri Contributor

@NicoleSulzberger ,

Yes, I see it was still reproducible with the reshape operation in 4.20. It was fixed in create mode, but not in reshape. This is a good find. I just tested with the latest cdn build and it seems to be resolved with both create and reshape. Can you confirm with this cdn?

0 Kudos
NicoleSulzberger
Regular Contributor

Hi @JoseBanuelos,

Yes, it looks fine with this version. Thanks a lot for the deeper investigation!

bye, Nicole