bozdoz / wp-plugin-leaflet-map

Add leaflet maps to Wordpress with shortcodes
https://wordpress.org/plugins/leaflet-map/
GNU General Public License v2.0
140 stars 71 forks source link

layerswitch on leaflet-geojson polygons #183

Closed RayHollister closed 1 year ago

RayHollister commented 1 year ago

I am trying to add a layerswitch to toggle a polygon laye on and off, but I can't seem to figure out how to make it work. I have Leaflet Map and Extensions for Leaflet Map both installed. Here's my shortcode:

[leaflet-map fitbounds height=1000 detect-retina zoomcontrol scrollwheel tileurl=https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png attribution='© OpenStreetMap contributors © CARTO.' zoom=16]

[leaflet-geojson src=https://raw.githubusercontent.com/RayHollister/JacksonvilleNeighborhoods/main/neighborhoods.geojson]{NAME}[/leaflet-geojson] [layerswitch] [markerClusterGroup feat="name" strings="neighborhoods" groups="Neighborhoods"] [fullscreen] [zoomhomemap fit]

hupe13 commented 1 year ago

[markerClusterGroup feat="name" strings="neighborhoods" groups="Neighborhoods"] is only for markers, inluding geojson markers. Switching other geojson on and off isn't possible (yet) and needs extra programming. You can take a look at [hover].

RayHollister commented 1 year ago

Darn. I thought that might be the case. Thanks for that clarification.

I'll work on integrating this plugin (https://github.com/ptma/Leaflet.Legend) into my Wordpress plugin, assuming you don't want to add it to Extensions for Leaflet Map.

hupe13 commented 1 year ago

I think this function might also interest others. If you want to help me, feel free to do so.