group geosjon
-
Hi there,
I’d like to be able to toggle various geojson shapes on/off.
Now i read this is possible:
https://leafext.de/en/parentgroup/parentgroupgeojson/
https://leafext.de/en/grouping/geojsonfeature/But how can i add a value/id or group? Can this be set in wordpress or should i already add these in ex QGIS (not sure how to, but still)?
Regards, Ed’
-
You can groups shapes from geojson files. This is an example for gpx, it is similar to geojson. If your shapes have a
propertyand differentvalueyou can group. I have a lot of examples for markers, maybe because Leaflet.FeatureGroup.SubGroup has them also.Do you have an example geojson file?
Hi hupe13,
Looking at your gpx-example i believe i understand the leaflet-shortcodes. But it feels i do need something to use as id/property/value to make the grouping possible?
Basically i used 2 sorts of geojson’s.- Some geojson’s i got by:
looking up the id at OSM; and
use that id @ https://polygons.openstreetmap.fr/index.py to get the geojson;
ex: Amsterdam @ https://polygons.openstreetmap.fr/index.py?id=47811 - Some of the geojson’s i merged with QGIS (loading the geojson’s, merge vectors and output the feature as new geojson).
Now the geojson’s made with QGIS do have the following code in the file itself:
{
"type": "FeatureCollection",
"name": "area-x",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "layer": "area-x-layer", "path": "/Users/area-x.geojson" }Maybe i can group/toggle with ‘name’ or ‘layer’? Or otherwise add some id/property/value through QGIS or smt similar?
(Presuming these are read before the geojson’s are turned into SVG’s on the leaflet-map itself on the page itself.)
Hope this helps a bit? Cheers, Ed’
Try it. Load first all geojson files with
leaflet-geojsonand then use similar:[leaflet-featuregroup property="name" values="area-x,area-y" groups="group a,group b"]
[leaflet-featuregroup property="name" values="area-z" groups="group c"]
[leaflet-featuregroup property="name" values="area-a" groups="group a"]The second
"group a"is not a typo. It is important, that the count ofvaluesandgroupsmatch. Open the developer console and see the logs.You can also try:
[leaflet-featuregroup property="layer" values="area-x-layer" groups="group a"]But I don’t know, if this works.
Sweet,
The property ‘layer’ works (‘name’ doesn’t somehow). Matching the amount of values and groups requires some focus, but makes sense.
As i don’t want áll of the areas i was able to add them to a parent-group:[leaflet-parentgroup parent="Group 1" childs="a,b,c,d"]
[leaflet-parentgroup parent="Group 2" childs="x,y,z"]Could i hide the child-groups and just show the parent-groups somehow btw? (Don’t see this @ https://leafext.de/en/parentgroup/parentgroup/)
Now i do need to run the geojsons that i got directly from OSM through QGIS to add attributes i can use to group/toggle the geojsons.
Thanks for the fast support. Cheers! Ed’Could i hide the child-groups and just show the parent-groups somehow btw?
No, this is not possible. But you can adjust the initial visibility of a group with
visible:[leaflet-featuregroup property="layer" values="layer-area-a" groups="group a" visible=0]In the mentioted example I use
leaflet-optiongroup.leaflet-optiongroupandleaflet-featuregrouphave some same options.I just realized that the navigation on my website is somehow incorrect. But it’s the same documentation as in the backend. You have it there too: /wp-admin/admin.php?page=extensions-leaflet-map&tab=featuregroup
Thanks,
i did see the ‘visibility’-option, but then the shape is hidden also. (Even tried something with ‘collapsed=”1″‘ or ‘collapsed=”true”‘ , which showed the groups behind this layers-icon.. which looked fairly fancy – but less intuitive for visitors to use.
And the docs are useful as is, saw some examples.
Anyway, I’ll keep the toggles open, thanks!
collapsedis for all L.control: https://leafext.de/en/control/lcontrol/. The example for Geojson Marker shows a collapsed control.Yup, it looks fancy imo – just less intuitive for visitors. Either way, lots of options!
In the past i used google-maps, but starting to prefer OSM over gmaps.
Cheers, Ed’
- Some geojson’s i got by:
The topic ‘group geosjon’ is closed to new replies.