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 | |
| parent | e63f0bc88eda8c5907d5dd4a312052b0e5c8f5ce (diff) | |
| download | chouette-core-64fd52a1ba9a29c19409cd9778eed44e6e14fb33.tar.bz2 | |
Add features for line map
| -rw-r--r-- | Gemfile.lock | 4 | ||||
| -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 |
5 files changed, 37 insertions, 13 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 697fe1022..946965170 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -48,7 +48,7 @@ GIT GIT remote: git://sim.dryade.priv/user_interface - revision: ee5c629c3aaea61036abfc7c7287a3b80abc7d63 + revision: 724621255c1ea243c433f6fb5e6dd726690f84b8 specs: user_interface (0.0.1) rails (~> 3.1.0) @@ -189,7 +189,7 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) map_layers (0.0.5) - mime-types (1.17.2) + mime-types (1.18) multi_json (1.0.4) net-scp (1.0.4) net-ssh (>= 1.99.1) 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" /> |
