Created
January 21, 2012 16:19
-
-
Save yaph/1653194 to your computer and use it in GitHub Desktop.
Load JSON data and then dynamically load Google Maps API V3 to display a map using the data
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
$.getJSON('http://example.com/getjson, function(dataJSON) { | |
$.getScript('http://www.google.com/jsapi?key=API_KEY', function(data, textStatus){ | |
function mapLoaded() { | |
var myOptions = { | |
center: new google.maps.LatLng(dataJSON.lat, dataJSON.long), | |
zoom: 8, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); | |
} | |
google.load('maps', '3', {'callback' : mapLoaded, 'other_params':'sensor=false'}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment