Ajout d'une carte des prochains événements et des lugs, pour l'instant non cliquable
parent
ad0f8aa066
commit
92105b0b9c
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
@ -0,0 +1,18 @@
|
||||
# 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://coffeescript.org/
|
||||
|
||||
#= require openlayers-rails
|
||||
|
||||
$(document).ready ->
|
||||
map = new OpenLayers.Map 'map'
|
||||
layer = new OpenLayers.Layer.WMS 'OpenLayers WMS',
|
||||
'http://vmap0.tiles.osgeo.org/wms/vmap0', {
|
||||
layers: 'basic'
|
||||
}
|
||||
map.addLayer layer
|
||||
map.setCenter new OpenLayers.LonLat(2.5, 47), 6
|
||||
map.addControl new OpenLayers.Control.LayerSwitcher()
|
||||
|
||||
map.addLayer eventsLayer
|
||||
map.addLayer lugsLayer
|
@ -0,0 +1,3 @@
|
||||
#map
|
||||
width: 100%
|
||||
height: 40em
|
@ -0,0 +1,19 @@
|
||||
class MapsController < ApplicationController
|
||||
def index
|
||||
@events = Event
|
||||
if (params[:region] && params[:region].present? && params[:region] != 'all')
|
||||
@events = @events.region(params[:region])
|
||||
end
|
||||
@events = @events.tag(params[:tag]) if (params[:tag])
|
||||
|
||||
@events = @events.where('start_time > ?', 360.days.ago).order :id
|
||||
|
||||
@cities_event = @events.collect { |event|
|
||||
City.find_by_majname event.city.gsub('-', ' ').upcase
|
||||
}.uniq.keep_if { |city| city }
|
||||
|
||||
@cities_lug = Lug.all.collect { |lug|
|
||||
City.find_by_majname lug.city.gsub('-', ' ').upcase
|
||||
}.uniq.keep_if { |city| city }
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module MapsHelper
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
%h2=t '.title'
|
||||
|
||||
#map
|
||||
|
||||
:javascript
|
||||
var eventsLayer = new OpenLayers.Layer.Markers("#{t '.events'}");
|
||||
eventsLayer.setVisibility(true);
|
||||
var iconSize = new OpenLayers.Size(20, 20);
|
||||
var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
|
||||
|
||||
- for city in @cities_event
|
||||
:coffee
|
||||
marker = new OpenLayers.Marker(
|
||||
new OpenLayers.LonLat(#{city.longitude}, #{city.latitude})
|
||||
#new OpenLayers.Icon(<<iconURL>>, iconSize, iconOffset)
|
||||
)
|
||||
eventsLayer.addMarker marker
|
||||
|
||||
:javascript
|
||||
var lugsLayer = new OpenLayers.Layer.Markers("#{t '.lugs'}");
|
||||
lugsLayer.setVisibility(true);
|
||||
var iconSize = new OpenLayers.Size(20, 20);
|
||||
var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h);
|
||||
|
||||
- for city in @cities_lug
|
||||
:coffee
|
||||
marker = new OpenLayers.Marker(
|
||||
new OpenLayers.LonLat(#{city.longitude}, #{city.latitude})
|
||||
new OpenLayers.Icon("/assets/team.png", iconSize, iconOffset)
|
||||
)
|
||||
lugsLayer.addMarker marker
|
@ -0,0 +1,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MapsHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in New Issue