我正在使用Geoserver在传单上显示WMS格式的图层点。
var owsrootUrl = 'http://localhost:8081/geoserver/cite/wms';
var defaultParameters = {
service : 'WFS',
version : '2.0',
request : 'GetFeature',
transparent: true,
typeName : 'cite:transacthcmgis_salesaggregated',
outputFormat : 'json',
format_options : 'callback:getJson',
SrsName : 'EPSG:4326'
};
var geojsonMarkerOptions = {
radius: 0,
fillColor: "#ff7800",
color: "#000",
weight: 0,
opacity: 0,
fillOpacity: 0.0
};
var parameters = L.Util.extend(defaultParameters);
var URL = owsrootUrl + L.Util.getParamString(parameters);
var ajax = $.ajax({
url : URL,
dataType : 'json',
jsonpCallback : 'getJson',
success : function (response) {
L.geoJson(response, {
style: function(geoJsonPoint, latlng) {
return L.marker(latlng, geojsonMarkerOptions);
},
onEachFeature: function (feature, url) {
popupOptions = {maxWidth: 250};
url.bindPopup("<b>Pharmacy Name:</b> " + feature.properties.customername_clients
+ "<br><b>adm0_zscore: </b>" + feature.properties.adm0_zscore
+ "<br><b>adm1_zscore: </b>" + feature.properties.adm1_zscore
+ "<br><b>adm2_zscore: </b>" + feature.properties.adm2_zscore
+ "<br><b>adm3_zscore: </b>" + feature.properties.adm3_zscore
,popupOptions);
}
}).addTo(map);
zscore.on('add', function(evt) {
if (!map.hasLayer(geoJSON)) map.addLayer(geoJSON);
});
zscore.on('remove', function(evt) {
if (map.hasLayer(geoJSON)) map.removeLayer(geoJSON);
});
}
});
我将笔触的样式设置为0,填充不透明度设置为0.0,仍然可以返回默认的小叶点图标,如您在此图片中看到的那样?
我如何显示它们“透明”?
答案 0 :(得分:2)
让我引用Leaflet documentation about L.GeoJSON
's pointToLayer
property,重点是我的:
一个
Function
,用于定义GeoJSON指向如何生成Leaflet图层。在添加数据时,会在内部调用它,并传递GeoJSON点特征及其LatLng
。 默认为产生默认的Marker
。
请注意,默认的pointToLayer
回调会忽略传递给style
构造函数的L.GeoJSON
选项的值。
我想您会想提供一个自定义的pointToLayer
回调,这样poitn功能就会生成L.CircleMarker
。 Leaflet GeoJSON tutorial中提供了有关操作方法的信息。