Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps does not update tiles while dragging

I have to use the google maps javascript api in a webview. The problem is that while dragging the map the missing tiles won't be loaded. In a browser on my desktop pc I can't get the same behaviour but loading the tiles while dragging the map around. In the picture I hold the map and nothing happens till I release my finger.

Dragging and holding

I have found an issue (not perfectly fitting on my problem but kinda close) in the gmaps bugtracker and tried all the solutions mentioned: https://code.google.com/p/gmaps-api-issues/issues/detail?id=1448

This is what I've tried so far:

// Setting the maps div container to a fixed size #map-canvas {     height: 600px;     width: 600px; }  // Emit resize trigger on mouse move $(document).ready(function () {     $("#map-canvas").mousemove(function (event) {         setTimeout(function () {              google.maps.event.trigger(map,'resize');             map.setZoom(map.getZoom());         }, 100);     }); });  // loading Google Maps API after document has been loaded function loadScript() {   var script = document.createElement('script');   script.type = 'text/javascript';   script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +       'callback=initialize';   document.body.appendChild(script); } window.onload = loadScript; 

The code is working and the mousemove event gets fired. I am using android:minSdkVersion="19" on my nexus 10 device.

like image 674
seveves Avatar asked Mar 14 '14 11:03

seveves


People also ask

Why does Google Maps stop updating?

If your maps don't update or you don't get real-time data, chances are your phone has lost connection to the internet, or your phone's internet is too slow. In this case, ensure there's an active internet connection on your Android device.

How do you refresh a marker on Google Maps?

To reload the markers, when you create then, push them to an array. Then create a function where you iterate through the array, setting the markers map as null. After this, erase the array.

How do I drag a location on Google Maps?

Open or create a map. Click an existing place on the map. In the bottom right of the box that appears, use the icons to make changes. Move place: Drag the feature on the map.


1 Answers

Try this... This problem raise only when map get resized.

google.maps.event.addDomListener( map, 'drag', function(e) {     google.maps.event.trigger(map,'resize');     map.setZoom(map.getZoom()); }); 
like image 56
Sourabh Upadhyay Avatar answered Sep 27 '22 21:09

Sourabh Upadhyay