I am trying to implement Leaflet in my angular 7 project i try to google the solution but nothing all the result is for angularjs or vanilla javascript.
This is my ts file:
ngAfterViewInit(): void {
//Init map & add tile
this.map = new Map('map').setView([25.1220946, 56.3342466], 13);
tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}').addTo(this.map);
//onClick
this.map.on("click", function(e){
//Add marker
this.myMarker = marker([e.latlng.lat, e.latlng.lng]).addTo(this.map);
// console.log();
console.log(`Your lat is : ${e.latlng.lat} and your lang : ${e.latlng.lng}`);
});
}
FYI it's not duplicate, the same question is 5 years old everything is different now.