I am using Google Maps v3 API on one of my websites and everything was working fine. However quite suddenly since yesterday every time i try to access the map page i 'm getting this error:
Error: Script terminated by timeout at:
f@http://maps.googleapis.com/maps-api-v3/api/js/32/1a/map.js:1:175
next@http://maps.googleapis.com/maps-api-v3/api/js/32/1a/map.js:2:310
hx@http://maps.googleapis.com/maps-api-v3/api/js/32/1a/map.js:7:457
_.jl.prototype.Yb<@http://maps.googleapis.com/maps-api-v3/api/js/3/1a/map.js:54:163
Uy@http://maps.googleapis.com/maps-api-v3/api/js/32/1a/map.js:38:313
Xy/<@http://maps.googleapis.com/maps-api-v3/api/js/32/1a/map.js:39:307
Any idea why is this happened ?
This is the issue with Latitude and Longitude.
Latitude and Longitude should be of 'float' numbers. If we pass other datatypes to it, it freezes the browser as it is waiting for google response with wrong datatype.
function drawMap( lat, lng ) { lat = parseFloat(lat); lng = parseFloat(lng); if ( ! isNaN( lat ) && ! isNaN( lng ) ) // Before sending it to google let check if they are valid values
{
var mapOptions = {
center: new google.maps.LatLng(44.5452, -78.5389),
zoom: 5
};
map = new google.maps.Map(document.getElementById('vehicle_country_region_from_map'), mapOptions);
}}
How does your code look like? Today, I realized I had the same problem (it's been working for the last couple of months) and came here for answers, but ultimatly stumbled upon a solution myself.
Old code:
<script>
function initMap(lat,lon) {
var uluru = {lat: parseFloat(lat), lng: parseFloat(lon)};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
}
Changed to:
<script>
function initMap(lat,lon) {
var uluru = {lat: lat, lng: lon};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: uluru
});
}
Notice that after the change, I parse my latidue & longitude strings to floats before calling the initMap function.
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