Problem/Motivation

I created a custom geolocation Location plugin that would set coordinates and zoom level by having the getCoordinates function return an array with values like these:

[
  'lat' => 51.1503091,
  'lng' => 4.8516256,
  'zoom' => 8,
];

This all works fine when I run the project locally on ddev. So even though in the general google maps settings the default zoom level is set to 14, if I enable this plugin in the map center settings, the map will be rendered focused on the given coordinates at the given zoom level (8 instead of 14). This is great.

But when I deployed the settings and code to production, the google map would focus on the correct coordinates, but with the wrong zoom level (14 instead of 8).

After a very, very long time of troubleshooting and testing I found a working solution.

Proposed resolution

In modules/geolocation_google_maps/js/MapProvider/GoogleMaps.js,
Change:
zoom: this.settings.google_map_settings.zoom ?? 2,
Into:
zoom: this.settings.zoom ?? this.settings.google_map_settings.zoom ?? 2,

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

flyke created an issue. See original summary.

flyke’s picture

I am also including the change from #3584097 here as they overlap and it is not possible to have both issues fixed in separate patches as they prevent each other from applying.