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

What's the best way to add bulk markers to a map? #179

Open dreadedhamish opened 1 year ago

dreadedhamish commented 1 year ago

I've got 350 markers to add, and I plan to use clustering to avoid performance issues. I expected to find an option to load a text file (CSV, JSON...), but can't see that option.

Should I investigate GeoJSON? From reading all the github issues it seems to offer this functionality.

dreadedhamish commented 1 year ago

OK - 1 minute into investigating and yes, GeoJSON is just a JSON file structured for geolocation.

hupe13 commented 1 year ago

Have a look at Extensions for Leaflet Map.

gmbo commented 1 year ago

I can only confirm that. Leaflet Map and Extensions for Leaflet Map is the best combination and puts many functions together optimally. and geojson is the file format with the most possibilities. But it requires at least PHP7 to work with all functions. I have made an example with over 3000 POIs stored in 7 geojson files for selectability and different icons.

The Shortcode for the example:

[leaflet-map  scrollwheel fitbounds height=700]

[leaflet-geojson src="../../../../wp-content/uploads/test/c23.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc23s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c22.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc22s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c21.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc21s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c20.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc20s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c19.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc19s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c18.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc18s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]
[leaflet-geojson src="../../../../wp-content/uploads/test/c17.geojson" iconurl="../../../../wp-content/uploads/test/Fahne_fc17s0.svg" iconAnchor="27,27" iconsize="54,54"] {name}{description}[/leaflet-geojson]

[layerswitch]
[markerClusterGroup feat="iconUrl" strings="Fahne_fc23s,Fahne_fc22s,Fahne_fc21s,Fahne_fc20s,Fahne_fc19s,Fahne_fc18s,Fahne_fc17s" groups="Fahnen Challenge 2023,Fahnen Challenge 2022,Fahnen Challenge 2021,Fahnen Challenge 2020,Fahnen Challenge 2019,Fahnen Challenge 2018,Fahnen Challenge 2017"]

[zoomhomemap]
[fullscreen]
[leaflet-scale]
[gestures]
dreadedhamish commented 1 year ago

Thanks @hupe13 and @gmbo - I've got a map up and running with GeoJSON and clustering with a few styling tweaks - very easy and I'm very thinkful this ahas been made into a wordpress plugin! The only think I didn't have success with was replacing markers with 1 count clusters.

@gmbo what doesn't work with <PHP7?

hupe13 commented 1 year ago

what doesn't work with <PHP7?

My plugin. You should upgrade PHP .

gmbo commented 1 year ago

@hupe13 With PHP7 everything works great, that's why you need the upgrade. I only have the case that other software in the account with PHP5 is still being migrated and then the installation uses an earlier version that does not have all the features. The example test site runs fine with PHP7. Thanks for the good plugins.

hupe13 commented 1 year ago

Yes it works with php 7, but it does not work with php < 7.