Skip to content

Instantly share code, notes, and snippets.

@minikomi
Created July 26, 2011 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minikomi/1106309 to your computer and use it in GitHub Desktop.
Save minikomi/1106309 to your computer and use it in GitHub Desktop.
Rough google maps partial
#map_canvas{:style=>"width: 400px; height: 400px"}
%script{:type => "text/javascript", :src=>"http://maps.google.com/maps/api/js?sensor=false"}
= javascript_include_tag 'map'
:javascript
$(document).ready(function(){mappit("#{address}")});
var mappit = function(address){
var geocoder, map, myOptions, mapCenterFunc;
geocoder = new google.maps.Geocoder();
myOptions = {
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
mapCenterFunc = geocoder.geocode({address: address}, function(result){
var center, marker;
center = result[0].geometry.location;
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
map.setCenter(center);
marker = new google.maps.Marker({
map: map,
position: center
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment