gpt4 book ai didi

javascript - 传单,否则 if = 不显示标记

转载 作者:行者123 更新时间:2023-12-03 02:44:08 24 4
gpt4 key购买 nike

我需要一种方法来在下面的“if and else if”处不显示标记或不可见标记。我有一个不允许在 map 上显示的要素属性值任何建议都会很棒,因为我没有想法

谢谢

pointToLayer: function(feature, latlng) {
var stt = feature.properties.sid;
var prd = feature.properties.utl;
var marker;

// filter
if (stt === 162341 && prd === 'A') {
marker = new L.marker(latlng, {icon: L.AwesomeMarkers.icon({icon: 'th-large', prefix: 'fa', markerColor: 'darkblue'}) });
} else if (stt === 162341 && prd === 'B') {
marker = new L.marker(latlng, {icon: L.AwesomeMarkers.icon({icon: 'navicon', prefix: 'fa', markerColor: 'darkblue'}) });
} else if (stt === 162341 && prd === 'AB') {
marker = new L.marker(latlng, {icon: L.AwesomeMarkers.icon({icon: 'list', prefix: 'fa', markerColor: 'darkblue'}) });
} else if (stt === 162341 && prd === 'X') {
marker = new L.marker(latlng, {icon: L.AwesomeMarkers.icon({icon: 'circle-thin', prefix: 'fa', markerColor: 'darkblue'}) });
} else {
marker = show no marker on map with this property value};
}
return marker;
}
}).addTo(map);

最佳答案

您正在使用 pointToLayer,它告诉我您正在使用 L.GeoJson 来解析一些 GeoJSON 并从中创建标记。

让我引用Leaflet documentation关于L.GeoJson的可能选项:

pointToLayer A Function defining how GeoJSON points spawn Leaflet layers. It is internally called when data is added, passing the GeoJSON point feature and its LatLng. The default is to spawn a default Marker

filter A Function that will be used to decide whether to include a feature or not. The default is to include all features

考虑到这一点,显然可以使用两者一个filter函数(对于那些不符合条件的点,它应该返回false)显示),然后是一个 pointToLayer 函数(它应该实例化未过滤掉的点的 Marker)。

关于javascript - 传单,否则 if = 不显示标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48174730/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com