标记未显示在Mapbox中

时间:2018-11-16 07:04:48

标签: mapbox geojson

我无法将标记加载到地图上。但是,当我执行console.log时,我可以看到坐标。我的geojson文件中缺少什么吗?我尝试使用此示例https://www.mapbox.com/mapbox-gl-js/example/live-geojson,但是在我的geojson中,我为每个单独的标记设置了属性,因此我不像他们那样添加图层属性。

var url = 'file.geojson';
map.on('load', function () {
window.setInterval(function() {
    map.getSource('markers').setData(url);
}, 6000);

map.addSource('markers', { type: 'geojson', data: url });

geojson

{
        "type": "FeatureCollection",
        "features": [
        {
            "type": "Feature",
            "geometry" : {
                "type": "Point",
                "coordinates": [-73.96121215820312, 40.66240692138672]
            },
            "properties" : {
                'marker-color': '#3bb2d0',
                'marker-size': 'large',
                'marker-symbol': 'stadium'
            }
        }]
}

0 个答案:

没有答案
相关问题