Skip to content

Instantly share code, notes, and snippets.

@seeingidog
Created December 1, 2011 21:23
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 seeingidog/1419984 to your computer and use it in GitHub Desktop.
Save seeingidog/1419984 to your computer and use it in GitHub Desktop.
function initialize() {
var flightPlanCoordinates = new Array();
var myLatLng = new google.maps.LatLng(0, 0);
var myOptions = {zoom: 6, center: myLatLng, mapTypeId: google.maps.MapTypeId.TERRAIN};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var geocoder = new google.maps.Geocoder;
- @coordinates.each do |c|
geocoder.geocode( { 'address': "#{c.location}"}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({map: map,position: results[0].geometry.location, title: "#{c.name}"});
flightPlanCoordinates.push(results[0].geometry.location);
}
});
alert(flightPlanCoordinates);
var flightPath = new google.maps.Polyline({path: flightPlanCoordinates, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2});
flightPath.setMap(map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment