The basemap of my application is created from tiled service which is published in our own server, like below
const mapBaseLayer = new TileLayer({
url: `${MAP_SVC_URL}/MapServer`
})const baseMap = new Basemap({
baseLayers: [this.mapBaseLayer],
title: "Test",
id: "test",
})const map = new ArcGISMap({
basemap: baseMap,
layers : [this.SatLayer, this.FeaturesLayer]
})let view = new MapView({
container: 'map-base',
map: map,
center: [103.85, 1.29],
zoom: 13,
constraints: {
lods: TileInfo.create().lods
}
})
I'm having an issue when getting lat long on mouse click. It's always null. I don't have an idea how to resolve this.
view.on("click", evt=> {
let point = view.toMap({ x: evt.x, y: evt.y })
console.log(point.latitude)
console.log(point.longitude)
})
Can somebody help me with this issue ? I have been trying fro 2 days. No luck so far.
Indika,
The view on click event already ha s a mapPoint property which is a Point geometry. So you code should look like this:
view.on("click", evt=> {
console.log(evt.mapPoint.latitude);
console.log(evt.mapPoint.longitude);
});