apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Directions #413

Closed pistiolasm closed 10 years ago

pistiolasm commented 10 years ago

Hi, I am new into to Ruby programming. I am using your gem which is absolutely awesome! I would also love to know how can i show directions from one place to another. Any help will be very appreciated. Thank you!

pistiolasm commented 10 years ago

This is what I have so far:

this is my location.rb

class Location < ActiveRecord::Base

attr_accessible :address, :latitude, :longitude, :title, :gmaps

acts_as_gmappable

def gmaps4rails_address self.address end

geocoded_by :address, :latitude => :fetched_latitude, # this will be overridden by the below :longitude => :fetched_longitude # same here

reverse_geocoded_by :latitude, :longitude

after_validation :geocode, :reverse_geocode, :if => :address_changed?

Geocoder.configure.units = :km Geocoder.configure.distances = :spherical

end

and my index has this:

<%= gmaps("map_options" => { "zoom" => 14, "auto_adjust" => false, "center_latitude" => :latitude, "center_longitude" => :longitude }, "markers" => { "data" => @json }, "direction" => { "data" => { "from" => "Boston, MA", "to" => "Cleveland, OH" }, "travelMode" => "DRIVING", "display_panel" => true, "panel_id" => "instructions" }) %>

apneadiving commented 10 years ago

please ask questions on stackoverflow, issues are meant to receive code issues