Module: Platformx::GooglemapHelpers
- Defined in:
- lib/platformx/google_map.rb
Instance Method Summary collapse
-
#x_google_map(css: "", id: "map", address: "", address_2: "", city: "", state: "", zip: "", zoom: "12", height: "400px", width: "520px") ⇒ Object
Start Google Map.
Instance Method Details
#x_google_map(css: "", id: "map", address: "", address_2: "", city: "", state: "", zip: "", zoom: "12", height: "400px", width: "520px") ⇒ Object
Start Google Map
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/platformx/google_map.rb', line 10 def x_google_map(css: "", id: "map", address: "", address_2:"", city:"", state:"", zip:"", zoom:"12", height: "400px", width: "520px") geo=Geokit::Geocoders::GoogleGeocoder.geocode "#{address} #{address_2}, #{city} #{state} #{zip}" #Get Lat & long cb = <<EOS <script src="https://maps.googleapis.com/maps/api/js"></script> <script> function initialize() { var mapCanvas = document.getElementById('#{id}'); var mapOptions = { center: new google.maps.LatLng(#{geo.ll}), zoom: #{zoom}, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(mapCanvas, mapOptions) } google.maps.event.addDomListener(window, 'load', initialize); </script> <div id="#{id}" class="#{css}"></div> EOS end |