Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.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 角度6-将Bing贴图添加到传单贴图_Angular_Leaflet_Bing Maps - Fatal编程技术网

Angular 角度6-将Bing贴图添加到传单贴图

Angular 角度6-将Bing贴图添加到传单贴图,angular,leaflet,bing-maps,Angular,Leaflet,Bing Maps,我正在使用传单bing层插件,以便添加一个带有传单的基于bing的地图。 由于我也在使用OSM,所以我同时导入传单和传单bing层。 进口声明如下: import * as L from 'leaflet'; import * as B from 'leaflet-bing-layer'; 以及组件内部传单的用法传单映射组件: constructor () { this.baseMaps = { OpenStreetMap: L.tileLayer ("https://{s

我正在使用
传单bing层
插件,以便添加一个带有传单的基于bing的地图。
由于我也在使用OSM,所以我同时导入
传单
传单bing层
。 进口声明如下:

import * as L from 'leaflet';
import * as B from 'leaflet-bing-layer';
以及组件内部传单的用法
传单映射组件

constructor () {
    this.baseMaps = {
      OpenStreetMap: L.tileLayer ("https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png", {
        attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="https://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
      }),
      BingMap: B.tileLayer.bing(LeafletMapComponent.BING_KEY, {type: 'AerialWithLabels'})
    };
  }
构造函数(){
此值为0.baseMaps={
OpenStreetMap:L.tileLayer(“https://{s}.tile.OpenStreetMap.fr/hot/{z}/{x}/{y}.png”{
属性:“©;,由提供”
}),
BingMap:B.tileLayer.bing(单张地图组件.bing_键,{键入:'AerialWithLabels'})
};
}
不幸的是,ling
BingMap:B.tileLayer.bing(…
得到一个错误: 无法读取未定义的属性“bing”

我没有在Angular和Typescript中找到Bing地图的任何工作示例,所以我猜这里缺少了一些东西

你知道我做错了什么吗?

你应该按如下方式导入传单bing层:

import * as L from 'leaflet';
import 'leaflet-bing-layer';
然后,您可以添加Bing平铺层,如下所示

L.tileLayer.bing(LeafletMapComponent.BING_KEY).addTo(map);
这将抛出一个类型错误

property 'bing' does not exist on type 'tileLayer' 
但您可以通过将L定义为自定义类型来克服此错误:

(L as any).tileLayer.bing(LeafletMapComponent.BING_KEY).addTo(map);

注意:我不会在构造函数上创建映射。我会选择一个生命周期钩子方法,这样我可以确保在加载视图后创建映射。

B的值是多少?