簡體   English   中英

MapBox:為點分配一個圖標

[英]MapBox: assign an icon to the points

我正在嘗試為來自 GeoJSON 的點分配一個圖標。 我使用這個片段:

    map.addSource('Punti di allerta', {
        type: 'geojson',
        data: source_attentionpoints, 
    });
    map.addLayer({
        'id': 'Punti di allerta',
        'type': 'circle',
        'source': 'Punti di allerta',
        'layout': {
            'icon-image': '{% static 'image/webgis/icons/warning50.png' %}',
            'icon-size': 0.5
        }
    });

我看到這兩個錯誤並且沒有呈現這些點:

錯誤:“layers.Punti di allerta.layout.icon-image:未知屬性“icon-image”” 錯誤:“layers.Punti di allerta.layout.icon-size:未知屬性“icon-size””

但是如果我使用這個片段而不是以前的片段,我可以毫無問題地看到所有點:

map.addLayer({
    'id': 'Punti di allerta',
    'type': 'circle',
    'source': 'Punti di allerta',
     'paint': {
         'circle-radius': 8,
         'circle-color': 'rgb(0,0,0)',
         'circle-opacity': 1.0,
         'circle-stroke-width': 4,
         'circle-stroke-color': 'rgb(200,200,200)',
         'circle-stroke-opacity': 1.0,
         'circle-blur': 0,
    }
});

我做錯了什么?

我找到了問題所在。 我的代碼中有兩個錯誤:

  1. 'type': 'circle'而不是'type': 'symbol'
  2. 在 add.Layer 之前我需要這個:

     map.loadImage( '{% static 'image/webgis/icons/warning50.png' %}', function(error, image) { if (error) throw error; map.addImage('warning', image); } );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM