Created
December 17, 2011 22:53
-
-
Save matiskay/1491692 to your computer and use it in GitHub Desktop.
Google Maps and Jquery
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
(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