Closed (outdated)
Project:
Leaflet
Version:
10.0.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
19 Aug 2023 at 22:34 UTC
Updated:
19 Dec 2023 at 20:19 UTC
Jump to comment: Most recent
Comments
Comment #2
b2f commentedThat doesn't sound great since a Drupal architecture is first revolving around php classes such as controllers, forcing to do those declarations in JS behaviors is adding a significant overhead to go back & forth between JS and php, although before d10 update it was perfectly fine.
Especially if the json data is held into entity fields and multiple maps are managed around a factored map structure.
Comment #3
itamair commentedWell ... @b2f what you say is not correct IMHO, as this approach is exactly matching the one that the Leaflet Map library is guiding to: https://leafletjs.com/examples/geojson/
L.geoJSON(geojsonFeature).addTo(map);(and of course Leaflet JS library is not expecting any PHP Object / Class / Controller for doing that).
In case of the Leaflet Drupal module this approach is coping the case the user wants to add to the Leaflet Map a GeoJson content/file that is external to the CMS, and indeed without using Drupal controller, PHP Object / class etc. for injecting a Geojson content before going into the JS front-end processing / layer (what's the real need for that? in case of Geojson external from the CMS?).
But if you really want to use a Drupal controller, PHP Object / class etc.also in this case (and make your life so complicate, or easy, it depends from points of view) then you are still able to go with it and inject your geojson content into a PHP variable (string, array, whoever) and pass/add it in the ['#attached']drupalSettings property and (STILL, you don't have other options … isn’t it?) use in the JS front-end processing / layer.
Otherwise the GeoJson Geometries data can always be added in a Geofield (that supports Geojson string, but only in terms of geometries, and not other additional properties) and make it part of a Drupal Entity/Node content and render it the way you want in the FE (with Leaflet View, or a Field Formatter ... that is still a Controller).
Comment #4
itamair commentedBUT ... @b2f if you have a better idea and approach on this, please clearly provide your implementation (with a patch, or MR) to the module, so I/the community can understand what you mean and get a constructive contribution also from you.
May be I was just not able to understand what you have in mind on this.
Only complaining on the way things are working (or not working) here is not the an helping approach.
In the open source community, everybody is welcome when coming with solid & improving solutions (in practice).
Comment #5
itamair commented