Make form field widget for place only one simple point on Leaflet Map

Created on 25 November 2020, over 4 years ago
Updated 26 August 2024, 10 months ago

Problem/Motivation

Very often (maybe even in most cases) Geofield fields are used for store only one point (GPS coordinates), without any other types (multiple points, polygons, etc).

But Leaflet module provide not suitable widget for this task, because users allowed to create multiple points, and there are no ways to limit them to one only. And for place point on map, they before must do the selection of suitable tool via button "Draw Marker", event only one tool type is allowed.

Possible workaround for described problem is stop using Geofield module for "coordinates" field, and use Geolocation module instead, that have this feature out-of-the-box. But this is bad to have two similar modules installed in one site.

Proposed resolution

To solve described problem, for not make current form widget more complexly via adding additional options, good solution is provide separate form widget type "Leflet Point Map", that will allow for users to simply place one point on map, without any additional actions and with limit to add additional objects.

Example of this implementation via Leaflet widget we can lookup in Geolocation - Leaflet module.

If there are too hard to implement own widget for "Simple point", based on current widget code, can we simply copy the implementation from it and adjust it to work with Geofield field types?

Feature request
Status

Closed: works as designed

Version

10.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom kiwimind

    Sorry to raise this old thread, however it feels relevant again today.

    Seeing as the most recent version of the Geofield Map module does not appear to support Leaflet at the display end of things (only on the edit widget unless I'm missing something obvious), then this issue is valid again.

    It's still possible for editors to add more than one point to a geofield, and expecting them to select the add marker icon and right click to remove a marker does not feel particularly user friendly when it seems it would be better to replace the marker already placed when clicking on the map a second time.

  • Status changed to Closed: works as designed about 2 years ago
  • 🇬🇧United Kingdom kiwimind

    Ok, yeah, apologies.

    Apparently if you want to use leaflet and also restrict editors to a single marker placement, then enabling Geofield Map does do this.

    Thanks.

  • 🇮🇹Italy itamair

    Yes exactly ... at the moment you would use the Geofield Map widget (with Leaflet js library) to input new contents/geofields and still use the Leaflet Formatter/View Style to rodent them in the Front-End ...

  • How about opposite scenario, where user can draw multiple types Points + Lines, Polygons etc, but how to limit that on initial VIew only Points are displayed as Markers and only opening entity displaying everything?

Production build 0.71.5 2024