【问题标题】:Leaflet WMS Set points Transparent传单 WMS 设置点 透明
【发布时间】:2019-12-12 09:38:26
【问题描述】:

我正在使用 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,但它仍然返回默认的传单点图标,如您在这张图片中看到的那样?

我怎样才能将它们显示为“透明”?

【问题讨论】:

    标签: leaflet geoserver wms


    【解决方案1】:

    让我引用Leaflet documentation about L.GeoJSON's pointToLayer property,强调我的:

    Function 定义 GeoJSON 点如何生成 Leaflet 层。它在添加数据时在内部调用,传递 GeoJSON 点特征及其LatLng默认是生成一个默认的Marker

    请注意,默认的pointToLayer 回调会忽略传递给L.GeoJSON 构造函数的style 选项的值。

    我猜你会想提供一个自定义的 pointToLayer 回调,以便 poitn 功能产生 L.CircleMarkers 代替。 Leaflet GeoJSON tutorial 中提供了有关如何执行此操作的信息。

    【讨论】:

    • 感谢您的提示!我更新代码仍然无法弄清楚。仍然显示在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-12
    • 1970-01-01
    • 2018-05-18
    • 2011-03-02
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多