diff options
| author | Marc Florisson | 2012-06-04 08:50:31 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-06-04 08:50:31 +0200 |
| commit | 4bf9fdfc4ab517831413bb660874d323b49d9bb4 (patch) | |
| tree | 6ea6a773926e27cf49dc1880d8df1962cf886cfe | |
| parent | ee866a45955bac5cef7a8bdec58f86ffcb7cb702 (diff) | |
| parent | b362c0f021379cb6f1cf9bbe0b3b756209392150 (diff) | |
| download | chouette-core-4bf9fdfc4ab517831413bb660874d323b49d9bb4.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
| -rw-r--r-- | app/maps/application_map.rb | 27 | ||||
| -rw-r--r-- | app/maps/line_map.rb | 6 | ||||
| -rw-r--r-- | app/maps/network_map.rb | 8 | ||||
| -rw-r--r-- | app/maps/style_map/stop_areas_style_map.rb | 2 |
4 files changed, 39 insertions, 4 deletions
diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index dffb2501c..d7ee0b5a1 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -64,6 +64,33 @@ class ApplicationMap OpenLayers::Layer::Google.new "Google Satellite", :type => :"google.maps.MapTypeId.SATELLITE", :numZoomLevels => 22 end + def hover_control_display_name(layer) + OpenLayers::Control::SelectFeature.new( layer, { + :autoActivate => true, + :hover => true, + :renderIntent => "temporary", + :eventListeners => { + :featurehighlighted => JsExpr.new("function(e) { + feature = e.feature ; + popup = new OpenLayers.Popup.AnchoredBubble('chicken', + new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y), + null, + \"<div class='popup_hover'><b>\" + feature.attributes.name +\"</b></div> \", null, false, null); + popup.autoSize = true; + popup.displayClass = 'popup_hover'; + + feature.popup = popup; + map.addPopup(popup); + }"), + :featureunhighlighted => JsExpr.new("function(e) { + feature = e.feature; + map.removePopup(feature.popup); + feature.popup.destroy(); + feature.popup = null; + }") + } } ) + 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 diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index a7a9f892d..4d363b070 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -18,7 +18,11 @@ class LineMap < ApplicationMap 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.style_map)) + page.assign "stop_areas_layer", kml_layer(polymorphic_path([referential, line, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map) + + page << map.add_layer(:stop_areas_layer) + page << map.add_control( hover_control_display_name(:stop_areas_layer) ) + page << map.zoom_to_extent(bounds) if bounds end end diff --git a/app/maps/network_map.rb b/app/maps/network_map.rb index 35283a48f..760948a2a 100644 --- a/app/maps/network_map.rb +++ b/app/maps/network_map.rb @@ -14,10 +14,14 @@ class NetworkMap < ApplicationMap 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(google_satellite) + + page.assign "stop_areas_layer", kml_layer(polymorphic_path([referential, network, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map) + + page << map.add_layer(:stop_areas_layer) + page << map.add_control( hover_control_display_name(:stop_areas_layer) ) #page << map.add_layer(kml_layer(network, :styleMap => StyleMap::NetworkStyleMap.new( :style => network_style).style_map)) - page << map.add_layer(kml_layer(polymorphic_path([referential, network, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map)) page << map.zoom_to_extent(bounds) if bounds end end diff --git a/app/maps/style_map/stop_areas_style_map.rb b/app/maps/style_map/stop_areas_style_map.rb index c27f1fb65..0b481738c 100644 --- a/app/maps/style_map/stop_areas_style_map.rb +++ b/app/maps/style_map/stop_areas_style_map.rb @@ -15,7 +15,7 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap :graphicHeight => 25, :graphicOpacity => 1, :graphicXOffset => -12.5, - :graphicYOffset => 12.5 + :graphicYOffset => -12.5 } def initialize(options = {}) |
