Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## index.html.erb
- <h1>Listing restaurants</h1>
- <script type="text/javascript">
- google.load("maps", "2.x");
- // Call this function when the page has been loaded
- function initialize() {
- var map = getMap(<%= @location.lat %>, <%= @location.lng %>);
- var markerIcon = getMarkerIcon();
- var marker = new GMarker(map.getCenter(), {
- draggable: true, bouncy: false, icon: markerIcon});
- map.addOverlay(marker);
- var tinyIcon = getTinyIcon();
- // Set up our GMarkerOptions object literal
- markerOptions = { icon:tinyIcon };
- <% for restaurant in @restaurants %>
- point = new google.maps.LatLng(<%= restaurant.lat %>, <%= restaurant.lng %>);
- icon = new GMarker(point, markerOptions);
- map.addOverlay(icon);
- <% unless restaurant.menu_url.nil? || restaurant.menu_url.empty? %>
- GEvent.addListener(icon, "click", function() {
- MOOdalBox.open(
- "/restaurants/<%=restaurant.id%>/menu",
- "<%=restaurant.name %>",
- "500 900"
- );
- });
- <% end %>
- <% end %>
- GEvent.addListener(marker, "dragend", function() {
- var latlng = marker.getLatLng();
- var jSonRequest = new Json.Remote("/location/move", {
- onComplete: function(currentLocation){
- window.location.reload(true);
- }}).send({'lat': latlng.lat(), 'lng': latlng.lng()});
- });
- }
- google.setOnLoadCallback(initialize);
- </script>
- <div id="map"></div>
- <table>
- <thead>
- <tr>
- <th>Distance</th>
- <th>Name</th>
- <th>Address</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <% for @restaurant in @restaurants %>
- <tr>
- <td><%= "%.0f" % (@restaurant.distance_to(@location)*1000) %> meter</td>
- <td><%= link_to @restaurant.name, @restaurant %></td>
- <td><%=h @restaurant.address %></td>
- <td>
- <% if @restaurant.menu_url.nil? || @restaurant.menu_url.empty? %>
- <%= link_to 'Web', @restaurant.website if @restaurant.website %>
- <% else %>
- <%= link_to 'Menu', menu_restaurant_path(@restaurant),
- :rel => 'moodalbox 500 900',
- :title => @restaurant.name %>
- <% end %>
- </td>
- </tr>
- <% end %>
- </tbody>
- </table>
- <br />
- <%= link_to 'New restaurant', new_restaurant_path %>
Add Comment
Please, Sign In to add comment