Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created December 17, 2011 22:53
Show Gist options
  • Save matiskay/1491692 to your computer and use it in GitHub Desktop.
Save matiskay/1491692 to your computer and use it in GitHub Desktop.
Google Maps and Jquery
(function($){
// Get the current latitude and longitude
var latlong = function ($lat, $lng) {
return new google.maps.LatLng($lat.val(), $lng.val());
};
// Set the position of the map
var position = function () {
return new map.set_center(latlong());
};
// Instead of using document.getElementById('#map').
// this code use $('#map')[0] that has the same action.
var map = new google.maps.Map($('#map')[0], {
zoom : 8,
center : latlong(),
mapTypeId : google.maps.MapTypeId.ROADMAP
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment