小编fld*_*vem的帖子

如何在Leaflet中显示超出特定缩放级别的标签?

我对Leaflet库和一般的JavaScript都很陌生,而且我一直试图弄清楚如何基于缩放级别显示/隐藏传单Label(并且标记位于'cluster'层中) .

标记都是通过AJAX回调加载的onEachFeature,然后我使用它绑定弹出框和标签,然后我将geoJson标记层添加到地图中.

我只想在放大某个级别时显示标签,但我没有运气.我也尝试添加,leaflet.zoomcss.js但我想我没有正确使用它.

样品

var officesLayerGroup = L.markerClusterGroup();
var currentMakers;
function DiaplyLocalOffices(jqOffices) {

    currentMakers = new L.geoJson(jqOffices, {
        style: function (feature) {
            var c = feature.properties.markercolor;
            if (feature.properties.OfficeID == 0) {
                c = 'yellow';
            }
            return { color: c };
        },
        pointToLayer: function (feature, latlng) {
            return new L.CircleMarker(latlng, { radius: 7, fillOpacity: 0.5 });
        },

        onEachFeature: bindOfficePopup
    });
    officesLayerGroup.addLayer(currentMakers);
    map.addLayer(officesLayerGroup); 
}

function bindOfficePopup(feature, layer) {
    // This function adds the popup based on the …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery json leaflet

9
推荐指数
2
解决办法
6625
查看次数

标签 统计

css ×1

javascript ×1

jquery ×1

json ×1

leaflet ×1