【发布时间】:2019-12-06 21:33:59
【问题描述】:
我正在尝试在我的 angular 7 项目中实现 Leaflet,我尝试用谷歌搜索解决方案,但没有任何结果适用于 angularjs 或 vanilla javascript。
这是我的 ts 文件:
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}`);
});
}
仅供参考它不是重复的,同样的问题是 5 岁,现在一切都不同了。
【问题讨论】:
标签: javascript angular typescript api leaflet