Skip to content

Instantly share code, notes, and snippets.

@mattly
Forked from tdreyno/gist:162864
Created August 6, 2009 19:10
Show Gist options
  • Save mattly/163499 to your computer and use it in GitHub Desktop.
Save mattly/163499 to your computer and use it in GitHub Desktop.
$.fn.googleMap = function(address, options) {
var defaults = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.HYBRID
}
options = $.extend(defaults, options || {});
var map = new google.maps.Map(this[0], $.extend(options, {
center: new google.maps.LatLng(44.081996, -123.0286928),
}));
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK && results.length) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.set_center(results[0].geometry.location);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map
});
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment