在地图框 API 中向多点标记图层添加标题和描述



我正在使用以下JavaScript将经销商位置的引脚加载到地图上。这是使用 Mapbox API。

<%=getDealerPins()%> 方法向我返回一个格式为"[x,y],[x,y],[x,y]...."等。这似乎效果很好,因为我的引脚可以经常更换。

我需要知道的是,我是否可以对标题和说明属性执行相同的操作,以便为它们提供不同的名称?

<link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.css' rel='stylesheet' />
<script src='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.js'></script>
<style>
    #map {
        width: 100%;
        height: 600px;
    }
</style>
<div id='map' />
<script type='text/javascript'>
    var map = L.mapbox.map('map', 'guyh92.map-vt5qmr0v')
    L.mapbox.markerLayer({
        type: 'Feature',
        geometry: {
        type: 'MultiPoint',
        coordinates: [ <%=getDealerPins()%> ] 
    },
        properties: {
            title: ['Dealer'],
            description: ['1234'],
        }
    }).addTo(map);
    </script>

谢谢!

如果每个点都有自己的属性,则应使用点要素数组,而不是单个多点要素。

最新更新