Google maps base layer keeps disappearing

I am new to farms, and currently I am mapping our orchards(fields) using google satellite as base layer - the problem is, every time that I log in, the map on the dashboard page displays my areas (polygons), but the base layer is not selected (blank) ?

Also, I would like to know if it is possible to override certain field captions with more suitable names eg. areas to be orchards etc.

Hi @gertcoetzee - welcome to the farmOS community!

the problem is, every time that I log in, the map on the dashboard page displays my areas (polygons), but the base layer is not selected (blank) ?

This is a known issue, but we haven’t been able to pin it down yet. It seems to be somewhat inconsistent, and some have reported that it resolves itself. I personally have never experienced it, but others have. Here is the open bug report: https://github.com/farmOS/farmOS-map/issues/65

Have you tried the Mapbox layer? Curious if that works any differently than the Google layer for you.

Also, I would like to know if it is possible to override certain field captions with more suitable names eg. areas to be orchards etc.

It isn’t possible to override the work “Areas” without some significant hacking - it’s used throughout farmOS in many places.

Worth noting: we are currently hard at work on farmOS 2.x (a major upgrade), and “Areas” are now becoming new “Asset types” like “Land”, “Structure”, “Water”, etc. There will be a “Plant” asset type (called “Planting” in 1.x), and there has been talk about making an Orchard module that provides an “Orchard” asset type. So that might be something to watch for!

Thank you very much - I will try the Mapbox layer and see how it goes.

1 Like

Guys just a follow up - I have added a Mapbox API token, as well as my GoogleMaps API Key, and now everything works as it should !

3 Likes

Excellent! Glad to hear it @gertcoetzee!

That does seem to be the pattern with this “bug”… it doesn’t work at first, but then magically resolves itself. I wish I knew why! But at least it’s working now… :slight_smile:

It worked for me as well, thanks!

1 Like

Hello,

Are there any updates on the Google Maps integration with farmOS-map?

Mapbox does work but the basemaps are several years old and missing a lot of newly planted fields.
Which XYZ URL is being used?

I have no problem with this URL in QGIS: http://mt0.google.com/vt/lyrs=y&hl=en&x={x}&y={y}&z={z}

Thanks,
Mason

1 Like

@paul121 made a module for 2.x that adds Google layers in the same way we did in farmOS 1.x: GitHub - paul121/farm_map_google: Google maps integration with farmOS

Update: @Symbioquine has updated this for the new 2.x branch of farmOS-map, taken over maintenance, and created a release on drupal.org (so it’s now possible to run composer require drupal/farm_map_google: https://www.drupal.org/project/farm_map_google

We’re not going to include that in farmOS core, because the complexity it adds isn’t worth it IMO, but it can live on as an “add on” module for folks who want it. It still has a lot of the same “known issues” that come from the approach taken to legally integrate Google Maps with OpenLayers (by the upstream ol3-google-maps project).

I have no problem with this URL in QGIS: http://mt0.google.com/vt/lyrs=y&hl=en&x={x}&y={y}&z={z}

While that technically works, it is actually against the Google Terms of Service to use their layers outside of the Google Maps JavaScript library.

That’s why ol3-google-maps was made… and it basically works around that by hacking things together so the Google Maps JS is rendered underneath the OpenLayers map, and all click events are passed through from OpenLayers to the Google JS underneath. It’s a bit of a mess, but it’s the only way to support Google Map imagery in OpenLayers, unfortunately.

You can complain to Google if you want. I wish they were more open to allowing their imagery to be used in other libraries, even with a normal paid API key! I don’t get it, honestly.

Thanks, Mike!

Have you looked at Leaflet? They might have a better integration: Iván Sánchez Ortega / Leaflet.GridLayer.GoogleMutant · GitLab

Its good to know we can support Google Maps basemaps with a custom module. Yeah, the Google maps API is frustrating…I’ve been slapped with some expensive usage changes too.

1 Like

Have you looked at Leaflet? They might have a better integration: Iván Sánchez Ortega / Leaflet.GridLayer.GoogleMutant · GitLab

Yes! Although it was over 5 years ago… we considered switching to Leaflet when we were upgrading from OpenLayers 2 to 3, but at that point it didn’t quite meet our needs: https://www.drupal.org/project/farm/issues/2496845

Since then both Leaflet and OL have come a long way! We are pretty committed to OpenLayers now that we have our own farmOS-map.js library built on it. OL has been working well for us. But it doesn’t stop anyone from creating modules that use Leaflet maps in farmOS either! Lots of flexibility in the module and decoupled JS application layers.

Looking at the link, it sounds like that Leaflet.GridLayer.GoogleMutant library is working around the Google licensing issue as well. That link is actually really useful because it includes a list of various approaches that have been taken and the costs/benefits of each. Good resource to refer to! Seems like none of them are perfect.

I wish Google would just update their terms to allow use of the raw XYZ layers with an API key. It would save all this headache… :frowning:

That said… all of this is just a roundabout way of saying that we can’t officially support the XYZ layer approach, because it goes against the TOS. But that wouldn’t stop someone from making their own custom module… :wink:

But as a hosting service, Farmier can’t offer that module. I can’t afford to defend against Google’s Lawyers! :stuck_out_tongue:

1 Like

Incidentally, the updated version for 2.x (based on @paul121’s) can be found at GitHub - symbioquine/farm_map_google: Google maps integration with farmOS.

Baring any untoward changes on the Google Maps API side, I hope to keep the module well maintained going forward.

1 Like