Just starting with @asymmetrik/ngx-leaflet and Angular, so this might be a beginner's issue...
I'm working on an Angular.io (v5) project that incorporates the @asymmetrik/ngx-leaflet-tutorial-ngcli
Currently, I'm trying to retrieve the coordinates of a clicked point on the map. Following the discussion in Issue #51 get coordinates on click?, I added the following code:
map.on('click', () => { console.log(e.latlng); });
within:
onMapReady(map: Map) {
map.fitBounds(this.route.getBounds(), {
padding: point(24, 24),
maxZoom: 12,
animate: true
});
map.on('click', () => { console.log(e.latlng); });
}
This results in a runtime error:
Cannot find name 'e'.
It seems logical since 'e' is not defined in the context. So, I modified the code to:
map.on('click', (e) => { console.log(e.latlng); });
But now, I encounter an error stating:
Property 'latlng' does not exist on type 'LeafletEvent'
When I print 'e' to the console using console.log(e)
, I can see that the latlng property exists.
Why am I unable to access the coordinates using e.latlng
?
The dependencies for my project are as follows:
"@angular/cli": "1.4.7",
"@asymmetrik/ngx-leaflet": "^2.5.1",
"@types/leaflet": "^1.2.0",
"leaflet": "^1.2.0",