Code Snippet: ESRI JS API 4.11 get Latittude Longitude on mouse hover

ESRI JS API 4.11 get Latittude Longitude on mouse hover


//print point on mouse hover on map






mapView.on("pointer-move", function(event){
let mapPoint = mapView.toMap({x: event.x, y: event.y});
console.log(mapPoint);
});




//print point on mouse click on map

mapView.on("click", function(event){
let mapPoint = event.mapPoint;
console.log(mapPoint)
});

Both console statement will return the identical object as below which has latitude and longitude

  1. {__accessor__: b}
    1. cache(...)
    2. extent(...)
    3. hasM(...)
    4. hasZ(...)
    5. latitude(...)
    6. longitude(...)
    7. m(...)
    8. spatialReference(...)
    9. type(...)
    10. x(...)
    11. y(...)
    12. z(...)
    13. constructed(...)
    14. destroyed(...)
    15. initialized(...)

Comments

Popular posts from this blog

Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file