If you want to apply the style to all layers (except markers) then change your code to:
var address_points = new L.geoJson('', {
style: addressStyle,
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng);
},
onEachFeature: function (feature, layer) {
layer.bindPopup('<h1>'+feature.properties.address+'</h1>');
},
});
When you only want to apply the style to the CircleMarker you need to pass the style as object and not as function.
You can simply call the addressStyle function:
var address_points = new L.geoJson('', {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, addressStyle());
},
onEachFeature: function (feature, layer) {
layer.bindPopup('<h1>'+feature.properties.address+'</h1>');
},
});
or define addessStyle
as object:
var addressStyle = {
color: '#000',
fillColor: '#199900',
fillOpacity: 0.5,
radius: 100,
};
var address_points = new L.geoJson('', {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, addressStyle);
},
onEachFeature: function (feature, layer) {
layer.bindPopup('<h1>'+feature.properties.address+'</h1>');
},
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…