Include a "Find My Location" button without initial HTML5 geolocation default

Created on 8 September 2023, 10 months ago
Updated 26 September 2023, 9 months ago

Problem/Motivation

When setting the "Use HTML5 Geolocation to set Default Values" option on a geofield map form field, two things happen:

1) The Geofield value is automatically populated based on the user's current location.
2) A "Find my location" button appears, allowing the user to manually set the location.

My requirement is I need the "Find my location" button available, but I don't want the Geofield value to be set automatically on form load based on the user's location.

Is there a configuration or approach that would allow the user to manually trigger the "Find my location" action, without the system automatically determining and setting their location when the form initially loads?

Maybe the ability existed before this specific issue? https://www.drupal.org/project/geofield_map/issues/3280092 πŸ’¬ Automatic HTML5 Geolocation possible? Needs review

πŸ’¬ Support request
Status

Active

Version

3.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States chucksimply

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

Comments & Activities

  • Issue created by @chucksimply
  • πŸ‡ΊπŸ‡ΈUnited States chucksimply

    In /js/geolocation.js you can comment out the following code...

    if (options.geolocation) {
      updateGeoLocationFields($('#' + mapid, context).parents('.geofieldmap-widget-auto-geocode'), position, options);
    }
    

    This will disable the auto-population of the users location while keeping the "Find me" button.

    Would still be optimal to separate out these two options instead of bundling into one checkbox.

Production build 0.69.0 2024