在Angular 9的Mapbox地图上添加多边形

问题描述 投票:0回答:1

我正在使用mapbox-gl将Mapbox地图添加到我的Angular应用中,目前为止可以使用。该方法与这一here非常相似,但是我无法在该库的Angular端口中找到Polygon

这是我的组件代码:

private mapElement: ElementRef;
@ViewChild('map', { static: false }) set content(content: ElementRef) {
    if (content) { // initially setter gets called with undefined
        Object.getOwnPropertyDescriptor(mapboxgl, "accessToken").set(this.mapBoxKey);
        this.map = new mapboxgl.Map({
            container: content.nativeElement,
            style: this.globals.MapboxStyle,
            zoom: 12,
            center: [this.centerLng, this.centerLat]
        });

        // Add map controls
        this.map.addControl(new mapboxgl.NavigationControl());

        //at this point I'd like to add a polygon....

    }
}

[map.addLayer似乎接受类型为Layer的第一个参数,但是我不确定在哪里可以找到此类型,因此无法创建它的实例。

我在这里丢失包裹了吗?

angular mapbox mapbox-gl-js angular9
1个回答
0
投票

似乎您只是在使用标准的Mapbox-GL-JS API。文档在这里:https://docs.mapbox.com/mapbox-gl-js/api

您链接的示例使用的是mapbox.js,而不是Mapbox-GL-JS。那是一个完全独立的库。

© www.soinside.com 2019 - 2024. All rights reserved.