diff options
| author | Marc Florisson | 2012-08-21 11:52:36 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-08-21 11:52:36 +0200 | 
| commit | 2d756b1c5880986928ae1bc5912ee9038cf9c38f (patch) | |
| tree | ffe014ba1b676af665df9c1626fcd7f93fbbac2d /app/maps | |
| parent | d53d54ac6cbe9c82b2a14a19b4f5628ba9118ec4 (diff) | |
| download | chouette-core-2d756b1c5880986928ae1bc5912ee9038cf9c38f.tar.bz2 | |
hover on stop points. Refs #61
Diffstat (limited to 'app/maps')
| -rw-r--r-- | app/maps/application_map.rb | 10 | ||||
| -rw-r--r-- | app/maps/route_map.rb | 9 | ||||
| -rw-r--r-- | app/maps/style_map/route_style_map.rb | 9 | 
3 files changed, 21 insertions, 7 deletions
diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index f1b1d103d..d87915bc5 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -86,8 +86,10 @@ class ApplicationMap                                                :renderIntent => "temporary",                                                :eventListeners => {                                                  :featurehighlighted => JsExpr.new("function(e) { -          feature = e.feature ; -          popup = new OpenLayers.Popup.AnchoredBubble('chicken',  +          var feature = e.feature ; +          if (feature.attributes.inactive != undefined) +            return; +          var 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); @@ -98,7 +100,9 @@ class ApplicationMap            map.addPopup(popup);          }"),                                                  :featureunhighlighted => JsExpr.new("function(e) { -          feature = e.feature; +          var feature = e.feature; +          if (feature.attributes.inactive != undefined) +            return;            map.removePopup(feature.popup);            feature.popup.destroy();            feature.popup = null;   diff --git a/app/maps/route_map.rb b/app/maps/route_map.rb index daa3de23f..70e31e2e2 100644 --- a/app/maps/route_map.rb +++ b/app/maps/route_map.rb @@ -16,8 +16,15 @@ class RouteMap < 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([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new.style_map)) +      layer = kml_layer([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new.style_map) +      page.assign "routeLayer", layer +      selectFeature = OpenLayers::Control::SelectFeature.new( :routeLayer) + +      page << map.add_layer( :routeLayer) +      page << map.add_control( hover_control_display_name(:routeLayer) )        page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds + +      page.assign "selectFeature", selectFeature      end    end diff --git a/app/maps/style_map/route_style_map.rb b/app/maps/style_map/route_style_map.rb index 136cecba5..81ed483fb 100644 --- a/app/maps/style_map/route_style_map.rb +++ b/app/maps/style_map/route_style_map.rb @@ -5,6 +5,9 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap      @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end +  def select_style +    default_style.merge :externalGraphic => "/assets/icons/stop_area_hover.png" +  end    def default_style      {        :label => "${label}", @@ -19,7 +22,7 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap        :strokeWidth => 3,        :strokeLineCap => "round",        :strokeDashstyle => "solid", -      :externalGraphic => "/assets/map/${positionType}.png", +      :externalGraphic => "/assets/icons/${positionType}.png",        :graphicWidth => 12,        :graphicHeight => 12,         :graphicOpacity => 1,	 @@ -32,12 +35,12 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap    def context      context = {         :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ",  -      :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'departure'; } else if (feature.attributes.arrival != undefined) { return 'arrival'; } else { return 'interstop'; }} "  +      :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'stop_area_green'; } else if (feature.attributes.arrival != undefined) { return 'stop_area_red'; } else { return 'stop_area_black'; }} "       }    end    def style_map -    OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context})) +    OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), :select =>  OpenLayers::Style.new(style.merge( select_style), { :context => context}))    end  end  | 
