Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 当我使用带有角度7的传单传送机时,Namingm是未定义的_Angular_Typescript_Leaflet_Angular7 - Fatal编程技术网

Angular 当我使用带有角度7的传单传送机时,Namingm是未定义的

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

你好

我第一次使用Angular 7(typeScript)的JS库, 对于传单传送机,我使用这段代码,我有这个错误,你知道吗

组件1.ts:


出现此错误是因为尚未导入库,或者导入了库,但它在映射初始化后加载

像这样导入:

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:
        '&copy; <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:
        '&copy; <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);
  }