Angular 当我使用带有角度7的传单传送机时,Namingm是未定义的
你好强> 我第一次使用Angular 7(typeScript)的JS库, 对于传单传送机,我使用这段代码,我有这个错误,你知道吗 组件1.ts:Angular 当我使用带有角度7的传单传送机时,Namingm是未定义的,angular,typescript,leaflet,angular7,Angular,Typescript,Leaflet,Angular7,你好 我第一次使用Angular 7(typeScript)的JS库, 对于传单传送机,我使用这段代码,我有这个错误,你知道吗 组件1.ts: 出现此错误是因为尚未导入库,或者导入了库,但它在映射初始化后加载 像这样导入: import "leaflet-routing-machine/dist/leaflet-routing-machine.css"; import "leaflet-routing-machine"; 然后,当组件已加载时: ngOnInit() { th
出现此错误是因为尚未导入库,或者导入了库,但它在映射初始化后加载 像这样导入:
import "leaflet-routing-machine/dist/leaflet-routing-machine.css";
import "leaflet-routing-machine";
然后,当组件已加载时:
ngOnInit() {
this.map = L.map("map").setView([51.505, -0.09], 13);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(this.map);
L.Routing.control({
waypoints: [L.latLng(57.74, 11.94), L.latLng(57.6792, 11.949)],
routeWhileDragging: true
}).addTo(this.map);
}
ngOnInit(){
this.map=L.map(“map”).setView([51.505,-0.09],13);
L.tileLayer(“https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png”{
归属:
“©;贡献者”
}).addTo(此.map);
路由控制({
航路点:[L.latLng(57.74,11.94),L.latLng(57.6792,11.949)],
路线穿行:对
}).addTo(此.map);
}
请注意,由于API的限制,您有时应该在匿名浏览器模式下对其进行测试,以获取路由
ngOnInit() {
this.map = L.map("map").setView([51.505, -0.09], 13);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(this.map);
L.Routing.control({
waypoints: [L.latLng(57.74, 11.94), L.latLng(57.6792, 11.949)],
routeWhileDragging: true
}).addTo(this.map);
}