Yarin
Yarin

Reputation: 183559

Google maps data layer mouse events trigger map idle event

The Google Maps idle event is supposed to fire "when the map becomes idle after panning or zooming." (Google Maps JavaScript API V3 Reference, Events example page)

Yet, whenever the cursor passes over an element of a data layer, the idle event fires constantly, making it useless. (See https://jsfiddle.net/162tdb53/6/)

var map;
function initMap() {
  map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: {lat: -28, lng: 137}
  });

  // Load GeoJSON.
  map.data.loadGeoJson(
      'https://storage.googleapis.com/mapsdevsite/json/google.json');

  map.addListener('idle', function(event) {
    console.log('IDLE');
  });

}

Any insight appreciated

UPDATE

This bug was handled in issue tracker https://issuetracker.google.com/issues/74214837. It was marked as Fixed in version 3.32 on March 7, 2018.

Upvotes: 1

Views: 837

Answers (2)

canintex
canintex

Reputation: 638

Try using the release version of the API instead of the experimental version. You can do that by just adding v=3 to the js call.

<script async defer src="https://maps.googleapis.com/maps/api/js?v=3&key=###&callback=initMap"></script>

versus

<script async defer src="https://maps.googleapis.com/maps/api/js?key=###&callback=initMap"></script>

Upvotes: 1

Ren&#233; Thomas
Ren&#233; Thomas

Reputation: 11

Yep, you're not the only one. Looks like a Google Maps Api update in the last 24-hours has the map moving in the background.

Found this patch on a Drupal forum. Testing some things on my end and will let you know if we come up with anything. https://www.drupal.org/project/geolocation/issues/2950361

Upvotes: 1

Related Questions