Does anybody have any working code that allows one to use modernizr.load or yepnope to load the Google Maps API?
I am able to load JQuery & GMap3 using modernizr, however Google Maps API doesn't work unless I make a traditional script tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Please help me load Google Maps API with modernizr!</title>
<style>
#map { width: 500px; height: 300px; }
</style>
<script src="/js/modernizr-2.6.2.min.js"></script>
</head>
<body>
<h1>Please help me load Google Maps API with modernizr!</h1>
<div id="map">
Placeholder
</div>
<script>
function pageInit() {
$("#map").gmap3({
map:{
options: {
center: [18.01714, -76.750113],
zoom: 15,
mapTypeId: google.maps.MapTypeId.TERRAIN,
}
}
});
}
</script>
<!-- I WANT TO REMOVE THE SCRIPT TAG BELOW AND REPLACE WITH MODERNIZR LOAD! -->
<script src="//maps.google.com/maps/api/js?sensor=false&language=en"></script>
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<script>
Modernizr.load([{load: [
'//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',
'/js/gmap.jquery-5.1.1.min.js',
],complete: function () {loaded();}},]);
function loaded() {
$(document).ready(function() {
pageInit();
});
}
</script>
</body>
</html>
Well logic tells me I should do the following change after removing the script tag:-
Modernizr.load([{load: [
'//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',
'//maps.google.com/maps/api/js?sensor=false&language=en',
'/js/gmap.jquery-5.1.1.min.js',
But if I do this change the map doesn't load and I now get this error in the Javascript console:-
Load denied by X-Frame-Options: http://maps.google.com/maps/api/js?sensor=false&language=en does not permit cross-origin framing.
This is best I can come up with:-
It seems quicker with the preload! However I think it's grabbing the file twice judging by what Firebug tells me.