Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author hupe13

    (@hupe13)

    You can groups shapes from geojson files. This is an example for gpx, it is similar to geojson. If your shapes have a property and different value you 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?

    Thread Starter eddiebouncer

    (@eddiebouncer)

    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.

    1. 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
    2. 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’

    Plugin Author hupe13

    (@hupe13)

    Try it. Load first all geojson files with leaflet-geojson and 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 of values and groups match. 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.

    Thread Starter eddiebouncer

    (@eddiebouncer)

    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’

    Plugin Author hupe13

    (@hupe13)

    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-optiongroup and leaflet-featuregroup have 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

    Thread Starter eddiebouncer

    (@eddiebouncer)

    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!

    Plugin Author hupe13

    (@hupe13)

    collapsed is for all L.control: https://leafext.de/en/control/lcontrol/. The example for Geojson Marker shows a collapsed control.

    Thread Starter eddiebouncer

    (@eddiebouncer)

    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’

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘group geosjon’ is closed to new replies.