0
votes

I am using Geoserver to display a WMS format Layer points on leaflet.

        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);
                });
              }
            });

I am setting my style for the stroke to 0 and my fill opacity to 0.0 and it still returns me the default leaflet point icon as you can see in this picture?

enter image description here

How i can display them "transparent"?

1

1 Answers

2
votes

Let me quote the Leaflet documentation about L.GeoJSON's pointToLayer property, emphasis mine:

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.

Note that the default pointToLayer callback ignores the value of the style option passed to the L.GeoJSON constructor.

I guess you'll want to provide a custom pointToLayer callback, so that poitn features spawn L.CircleMarkers instead. There's information on how to do so in the Leaflet GeoJSON tutorial.