传单WMS设置点透明

问题描述 投票:0回答:1

我正在使用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,但仍能返回默认的小叶点图标,如您在此图片中看到的吗?

enter image description here

我如何显示它们为“透明”?

leaflet geoserver wms
1个回答
2
投票

让我引用Leaflet documentation about L.GeoJSON's pointToLayer property,重点是我的内容:

A L.GeoJSON定义GeoJSON指点如何生成小叶图层。当添加数据时,会在内部调用它,并传递GeoJSON点要素及其pointToLayer默认是生成默认的Function

请注意,默认的LatLng回调将忽略传递给Marker构造函数的pointToLayer选项的值。

我想您将要提供一个自定义的style回调,这样poitn会生成L.GeoJSONpointToLayer中提供了有关如何执行此操作的信息。

© www.soinside.com 2019 - 2024. All rights reserved.