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.
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.
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.
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.
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.
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()); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With