Problem/Motivation

I have a view with a Geolocation CommonMap with the 'Client Location Indicator' and 'Map Control - Locate' map features enabled.
When the google maps is rendered, I get these console.log errors:

Uncaught TypeError: this.googleMarker.position.lat is not a function
    update https://mysite.ddev.site/modules/contrib/geolocation/modules/geolocation_google_maps/js/GoogleMapMarker.js:45
    ClientLocationIndicator https://mysite.ddev.site/modules/contrib/geolocation/js/MapFeature/ClientLocationIndicator.js:30
    ClientLocationIndicator https://mysite.ddev.site/modules/contrib/geolocation/js/MapFeature/ClientLocationIndicator.js:27
    setInterval handler*ClientLocationIndicator https://mysite.ddev.site/modules/contrib/geolocation/js/MapFeature/ClientLocationIndicator.js:26
    loadFeature https://mysite.ddev.site/modules/contrib/geolocation/js/MapProvider/GeolocationMapBase.js:158
    promise callback*loadFeature https://mysite.ddev.site/modules/contrib/geolocation/js/MapProvider/GeolocationMapBase.js:156
    loadFeatures https://mysite.ddev.site/modules/contrib/geolocation/js/MapProvider/GeolocationMapBase.js:175
    loadFeatures https://mysite.ddev.site/modules/contrib/geolocation/js/MapProvider/GeolocationMapBase.js:174
    attach https://mysite.ddev.site/modules/contrib/geolocation/js/geolocation-map.js?v=4.x:315
    promise callback*attach/</< https://mysite.ddev.site/modules/contrib/geolocation/js/geolocation-map.js?v=4.x:314
    promise callback*attach/< https://mysite.ddev.site/modules/contrib/geolocation/js/geolocation-map.js?v=4.x:229
    attach https://mysite.ddev.site/modules/contrib/geolocation/js/geolocation-map.js?v=4.x:184
    attachBehaviors https://mysite.ddev.site/core/misc/drupal.js?v=11.3.6:166
    attachBehaviors https://mysite.ddev.site/core/misc/drupal.js?v=11.3.6:162
    <anonymous> https://mysite.ddev.site/core/misc/drupal.init.js?v=11.3.6:32
    listener https://mysite.ddev.site/core/misc/drupal.init.js?v=11.3.6:20
    domReady https://mysite.ddev.site/core/misc/drupal.init.js?v=11.3.6:26
    <anonymous> https://mysite.ddev.site/core/misc/drupal.init.js?v=11.3.6:31
    <anonymous> https://mysite.ddev.site/core/misc/drupal.init.js?v=11.3.6:34

I think this is because of changes in the Google Maps Marker API.

Steps to reproduce

- Use geolocation module 4.x or 4.0.0-beta2
- Create a view with a Geolocation CommonMap with the 'Client Location Indicator' and 'Map Control - Locate' map features enabled.

Proposed resolution

This is a solution for the new Google Maps Marker API that is backward compatible with old Google Maps Marker API.
Change:

    if (newCoordinates) {
      if (!newCoordinates.equals(this.googleMarker.position.lat, this.googleMarker.position.lng)) {
        this.googleMarker.position = this.coordinates;
      }
    }

Into:

    if (newCoordinates) {
      const position = this.googleMarker.position;
      const lat = typeof position.lat === "function" ? position.lat() : position.lat;
      const lng = typeof position.lng === "function" ? position.lng() : position.lng;

      if (!newCoordinates.equals(lat, lng)) {
        this.googleMarker.position = this.coordinates;
      }
    }
CommentFileSizeAuthor
geolocation-new-google-maps-marker-api.patch876 bytesflyke

Comments

flyke created an issue.

sourav_paul’s picture

I'm unable to reproduce the issue on 4.x by following steps but the patch seems still valid as it fixes property-style & function-style positions also stop depending upon exact google map return.

Thanks..