- 🇫🇷France b2f
What is the proper way to address this issue 6 years later in d10 ? Since the latest update is breaking backward compatibility with json layer in our case ...
- Status changed to Fixed
over 1 year ago 3:42pm 23 October 2023 - 🇮🇹Italy itamair
this looks a very old (almost 10 years) issue ... not resolved in Leaflet v7 itself.
Anyway here are the proper approaches on this:
OPTION 1
You want to manage the GeoJson content in Drupal,
you need to convert Geojson into WKT format as first step,
then generate a Node/Entity with it, & then you can do what you want with it ... such rendering it through the Leaflet Fields Formatter or the Leaflet View, or whatever (also fetching that content and rendering it in any Drupal page/route & controller).For converting it into a WKT format please refer to the geoPHP library that is a dependency of the Geofiled module → (dependency of Leaflet itself).
So from its Readme.md file take advantage (in your way of the following:$json = '{ "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }'; $multipoint = geoPHP::load($json, 'json'); $multipoint_points = $multipoint->getComponents(); $wkt = $multipoint->out('wkt');
Then something like:
$node->set('field_geofield', $wkt);
Ref: https://www.drupal.org/project/geofield/issues/2708529 →
PS: note you will be able to import into Drupal (and take advantage) only the geometries properties in the Geojson content, as the Geofield only supports those ... (and you will miss all the others properties potentially associated with each Geojson data/feature)
OPTION 2
If you don't need to manage the GeoJson content in Drupal, but only add to a Leaflet map generated with this Leaflet module then you should refer to this related issues guide: https://www.drupal.org/project/leaflet/issues/3382076 💬 Adding GeoJson resource into a Drupal Leaflet Map View Needs reviewHope 8and confident) this helps ...
Automatically closed - issue fixed for 2 weeks with no activity.