Created
November 28, 2012 19:47
-
-
Save chyld/4163627 to your computer and use it in GitHub Desktop.
This file contains 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
init file | |
GOOGLEKEY='AIzaSyBYPC8Wothfroho8ub3yM6wHtOE--Oovng' | |
application.html.erb | |
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?key=#{GOOGLEKEY}&sensor=false" %> | |
google.js | |
var map; | |
var canvas; | |
$(function(){ | |
}); | |
function display_map(lat, long, zoom) | |
{ | |
var mapOptions = { | |
center: new google.maps.LatLng(lat, long), | |
zoom: zoom, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
canvas = $('#map_canvas')[0]; | |
map = new google.maps.Map(canvas, mapOptions); | |
} | |
function add_marker(lat, long, title) | |
{ | |
var latlng = new google.maps.LatLng(lat, long); | |
var marker = new google.maps.Marker({position: latlng, map: map, title:title}); | |
} | |
show page: | |
<div id="map_canvas" style="width:300px; height:300px;"></div> | |
<script> | |
display_map(<%= @ninja.lat %>, <%= @ninja.long %>, 10); | |
add_marker(<%= @ninja.lat %>, <%= @ninja.long %>, 'nyc, baby!'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment