aboutsummaryrefslogtreecommitdiffstats
path: root/app/maps
diff options
context:
space:
mode:
authorLuc Donnet2012-03-21 17:20:15 +0100
committerLuc Donnet2012-03-21 17:20:15 +0100
commit64fd52a1ba9a29c19409cd9778eed44e6e14fb33 (patch)
tree65abd2d50afb4717c032e3e7a8589ff2f13e7bd6 /app/maps
parente63f0bc88eda8c5907d5dd4a312052b0e5c8f5ce (diff)
downloadchouette-core-64fd52a1ba9a29c19409cd9778eed44e6e14fb33.tar.bz2
Add features for line map
Diffstat (limited to 'app/maps')
-rw-r--r--app/maps/application_map.rb32
-rw-r--r--app/maps/line_map.rb9
2 files changed, 32 insertions, 9 deletions
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