The Google Maps base layer is hard-coded into the farm_map module, which means it is turned on even if you do not enter a Google API key and make Open Street Map your default base layer. Without an API key, Google causes an error message to be displayed in the map:

This page can't load Google Maps correctly.

Original description

Hi, in a new brand install, without selecting an Google Maps API (so system selects openstreetmaps, that is the right choice in my case), I get a Google warning in Dashboard map (and others).

I'm attaching an screenshot where you can see a map with a Google label in the bottom left corner, but I think it's using openstreetmaps info! And an anoying warning asking if this is my web ;-)

CommentFileSizeAuthor
farmosmap_Captura_2019-07-06_12-39-27.png47.11 KBcalbasi
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

calbasi created an issue. See original summary.

m.stenta’s picture

Thanks for the bug report @calbasi!

This is happening because currently Google layers are being added to the map all the time - regardless of whether or not you add the API key.

The solution to this will be to split the Google (and OSM) layers out into separate modules that can be enabled/disabled on their own. This isn't terribly difficult to do in theory. It might be a little more complicated because of the way the "default layer" setting is set up, though.

A bit of history, for reference:

Originally, farmOS only used Google Maps layers. With the addition of OSM (#2906648: Add openStreetMaps layer(s)), we also added a configuration option in the `farm_map` module that lets you select whether Google or OSM should be the default (#2772955: Add configuration for default map base layer).

As a follow-up to that, we also added a step to the farmOS installation form that allowed you to enter a Google Maps API key, and if you didn't enter one then the default map would be set to OSM (see #2884947: Add a shortcut configuration form for Google Maps API key and #2906652: Make OSM the default base layer if Google API key not available).

So, in order to fix this bug, a few things need to happen:

  1. Create separate sub-modules that provide Google and OSM layers: farm_map_google and farm_map_osm
  2. Update farmOS installation form step so that it provides options to enable one or both, and also to add a Google maps key (which should be optional as well, for testing).
  3. Update the way the "default" base layer setting works, so that modules can provide new options via a hook.
m.stenta’s picture

Title: Error using Openstreetmaps » Google Maps base layer cannot be turned off, shows message "This page can't load Google Maps correctly"
Issue summary: View changes

I'm updating the title and description of this issue to be more descriptive of the cause.

m.stenta’s picture

Regarding:

2. Update farmOS installation form step so that it provides options to enable one or both, and also to add a Google maps key (which should be optional as well, for testing).

There's a good chance we'll be rethinking some of the farmOS installation/configuration stuff soon in #3066502: farmOS Setup Wizard.

m.stenta’s picture

Status: Active » Fixed

This has been resolved by #3083352: Migrate to farmOS-map library. The Google layers are now provided by a separate farm_map_google module. If you are not using Google layers, this can be disabled.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.