Last active
August 29, 2015 14:03
-
-
Save thotbox/ed7dc982cdb45507dafb to your computer and use it in GitHub Desktop.
JavaScript: Google Map Fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IE8 Map Fix - Add data-lat and data-long attributes to .map-container | |
if ($('html').hasClass('lt-ie9')) { | |
if($('.map-container').length ) { | |
var mapLat = $('.map-container').attr('data-lat'); | |
var mapLong = $('.map-container').attr('data-long'); | |
setTimeout(function() { | |
google.maps.event.trigger(map, 'resize'); | |
map_map.setCenter(new google.maps.LatLng(mapLat,mapLong)); | |
}, 500); | |
} | |
} | |
// Center Map on Resize - Add data-lat and data-long attributes to .map-container | |
$(window).resize(function() { | |
if($('.map-container').length ) { | |
var mapLat = $('.map-container').attr('data-lat'); | |
var mapLong = $('.map-container').attr('data-long'); | |
setTimeout(function() { | |
google.maps.event.trigger(map, 'resize'); | |
map_map.setCenter(new google.maps.LatLng(mapLat,mapLong)); | |
}, 500); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment