diff options
| author | Luc Donnet | 2012-03-21 17:20:15 +0100 |
|---|---|---|
| committer | Luc Donnet | 2012-03-21 17:20:15 +0100 |
| commit | 64fd52a1ba9a29c19409cd9778eed44e6e14fb33 (patch) | |
| tree | 65abd2d50afb4717c032e3e7a8589ff2f13e7bd6 /app | |
| parent | e63f0bc88eda8c5907d5dd4a312052b0e5c8f5ce (diff) | |
| download | chouette-core-64fd52a1ba9a29c19409cd9778eed44e6e14fb33.tar.bz2 | |
Add features for line map
Diffstat (limited to 'app')
| -rw-r--r-- | app/assets/stylesheets/lines.css.scss | 4 | ||||
| -rw-r--r-- | app/maps/application_map.rb | 32 | ||||
| -rw-r--r-- | app/maps/line_map.rb | 9 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 1 |
4 files changed, 35 insertions, 11 deletions
diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index 9fd0e1638..022ba4955 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -169,8 +169,8 @@ #map { float: right; - width: 400px; - height: 250px; + width: 600px; + height: 400px; } diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index c5546f4d9..ed523eebe 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -9,12 +9,17 @@ class ApplicationMap OpenLayers::Projection.new(name) end - def id - "map" + def controls + [ OpenLayers::Control::LayerSwitcher.new(:ascending => true), + OpenLayers::Control::ScaleLine.new, + OpenLayers::Control::Navigation.new, + OpenLayers::Control::PanZoomBar.new, + OpenLayers::Control::Attribution.new + ] end - def controls - [] + def id + "map" end def map @@ -41,10 +46,27 @@ class ApplicationMap OpenLayers::Strategy::Fixed.new :preload => true end + def google_physical + OpenLayers::Layer::Google.new("Google Physical", + :type => :"google.maps.MapTypeId.TERRAIN") + end + + def google_streets + OpenLayers::Layer::Google.new "Google Streets", :numZoomLevels => 20 + end + + def google_hybrid + OpenLayers::Layer::Google.new "Google Hybrid", :type => :"google.maps.MapTypeId.HYBRID", :numZoomLevels => 20 + end + + def google_satellite + OpenLayers::Layer::Google.new "Google Satellite", :type => :"google.maps.MapTypeId.SATELLITE", :numZoomLevels => 22 + end + def kml_layer(url, options = {}) url = polymorphic_path([url.referential, url], :format => :kml) unless String === url protocol = OpenLayers::Protocol::HTTP.new :url => url, :format => kml - OpenLayers::Layer::Vector.new name, {:projection => projection("EPSG:4326"), :strategies => [strategy_fixed], :protocol => protocol}.merge(options) + OpenLayers::Layer::Vector.new name, {:projection => projection("EPSG:4326"), :strategies => [strategy_fixed], :protocol => protocol, :displayInLayerSwitcher => false}.merge(options) end end diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index 6ac671ae4..d0df83fed 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -9,13 +9,14 @@ class LineMap < ApplicationMap @line_style = line_style end - def controls - [ OpenLayers::Control::Navigation.new ] - end - def map @map ||= MapLayers::Map.new(id, :projection => projection("EPSG:900913"), :controls => controls) do |map, page| page << map.add_layer(MapLayers::OSM_MAPNIK) + page << map.add_layer(google_physical) + page << map.add_layer(google_streets) + page << map.add_layer(google_hybrid) + page << map.add_layer(google_satellite) + #page << map.add_layer(kml_layer(line, :styleMap => StyleMap::LineStyleMap.new( :style => line_style).style_map)) page << map.add_layer(kml_layer(polymorphic_path([referential, line, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new(true).style_map)) page << map.zoom_to_extent(bounds) if bounds diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 876a80da8..79f5d0b77 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,6 +4,7 @@ <title>CHOUETTE - <%= title %></title> <%= stylesheet_link_tag :application %> <%= javascript_include_tag :application %> + <script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script> <%= csrf_meta_tag %> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> |
