added popovers, added map on places/show page

This commit is contained in:
Skud committed 2013-08-12 12:36:09 +10:00
1 parent be9bc4ba4d
commit d30f8e443e
5 files changed
+49 -19

No files matched your search

@@ -1,17 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
map = L.map('map').setView([0.0, -0.0], 2);
L.tileLayer("http://{s}.tile.cloudmade.com/<%= ENV['CLOUDMADE_KEY'] %>/997/256/{z}/{x}/{y}.png", {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
<% Member.located.each do |m| %>
map.addLayer(
new L.Marker(
new L.LatLng(<%= m.latitude %>, <%= m.longitude %>)
);
);
<% end %>
+14
View File
@@ -24,6 +24,20 @@ class PlacesController < ApplicationController
@units = :km
end
location = Geocoder.search(Geocoder::Query.new(@place, :distance => @distance, :units => @units))
if location
@latitude, @longitude = location[0].coordinates
@sw_lat, @sw_lng, @ne_lat, @ne_lng = Geocoder::Calculations.bounding_box(
location[0].coordinates,
@distance,
options = { :units => @units }
)
else
@latitude, @longitude = [0, 0]
end
@nearby_members = @place ? Member.near(@place, @distance, :units => @units) : []
respond_to do |format|
+3
View File
@@ -0,0 +1,3 @@
%p= link_to member, member
%p= member.location
%p REPLACE THIS WHEN YOU MERGE FROM THE REDESIGNED HOMEPAGE!
+16
View File
@@ -1,3 +1,19 @@
-content_for :title, "Places"
%div#map{ :style => "height:500px"}
<script src="/assets/leaflet.js?body=1" type="text/javascript"></script>
:javascript
map = L.map('map').setView([0.0, -0.0], 2);
L.tileLayer("http://{s}.tile.cloudmade.com/#{ ENV['CLOUDMADE_KEY'] }/997/256/{z}/{x}/{y}.png", {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
- Member.located.each do |m|
:javascript
marker = new L.Marker(new L.LatLng(#{m.latitude}, #{m.longitude}));
marker.bindPopup('#{ escape_javascript( render :partial => 'members/popover', :locals => { :member => m }) }').openPopup();
map.addLayer(marker);
+16 -2
View File
@@ -1,7 +1,21 @@
-content_for :title, @place
%p This would be a google map.
= image_tag("http://placehold.it/700x300", :alt => "map goes here!")
<script src="/assets/leaflet.js?body=1" type="text/javascript"></script>
%div#map{ :style => "height:300px"}
:javascript
map = L.map('map').setView([#{ @latitude }, #{ @longitude }]).fitBounds([ [#{@sw_lat}, #{@sw_lng}], [#{@ne_lat}, #{@ne_lng}] ]);
L.tileLayer("http://{s}.tile.cloudmade.com/#{ ENV['CLOUDMADE_KEY'] }/997/256/{z}/{x}/{y}.png", {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
}).addTo(map);
- Member.located.each do |m|
:javascript
marker = new L.Marker(new L.LatLng(#{m.latitude}, #{m.longitude}));
marker.bindPopup('#{ escape_javascript( render :partial => 'members/popover', :locals => { :member => m }) }').openPopup();
map.addLayer(marker);
%h3
= Growstuff::Application.config.site_name