diff options
| author | Bruno Perles | 2015-12-16 10:02:04 +0100 |
|---|---|---|
| committer | Bruno Perles | 2015-12-16 10:02:04 +0100 |
| commit | 2590606c5912a85b8cb1aaa40c57dab67d75e7f7 (patch) | |
| tree | a63f7d70a32c6683c31511772d8367c3fa7a2a05 /app | |
| parent | d902ef10e8c6830ca0be00bd03b5e117cf6d7285 (diff) | |
| download | chouette-core-2590606c5912a85b8cb1aaa40c57dab67d75e7f7.tar.bz2 | |
Improvements
Diffstat (limited to 'app')
| -rw-r--r-- | app/maps/design/journey_pattern_style_map.rb | 53 | ||||
| -rw-r--r-- | app/maps/journey_pattern_map.rb | 12 | ||||
| -rw-r--r-- | app/maps/route_map.rb | 2 |
3 files changed, 34 insertions, 33 deletions
diff --git a/app/maps/design/journey_pattern_style_map.rb b/app/maps/design/journey_pattern_style_map.rb index b5d9ec7bc..b5323d6ae 100644 --- a/app/maps/design/journey_pattern_style_map.rb +++ b/app/maps/design/journey_pattern_style_map.rb @@ -2,46 +2,49 @@ class Design::JourneyPatternStyleMap < Design::GenericStyleMap attr_accessor :style def initialize(helpers, options = {}) - @helpers= helpers + @helpers = helpers @style = options[:style].present? ? default_style.merge(options[:style]) : default_style end def select_style - default_style.merge :externalGraphic => @helpers.assets_path_patch( "map/stop_area_hover.png") + default_style.merge externalGraphic: @helpers.assets_path_patch( "map/stop_area_hover.png") end + def default_style { - :label => "${label}", - :fontColor => "black", - :fontSize => "11px", - :fontWeight => "bold", - :labelAlign => "ct", - :labelXOffset => 0, - :labelYOffset => -15, - :strokeColor => "#000000", - :strokeOpacity => 1, - :strokeWidth => 3, - :strokeLineCap => "round", - :strokeDashstyle => "solid", - :externalGraphic => @helpers.assets_path_patch( "map/${positionType}.png"), - :graphicWidth => 12, - :graphicHeight => 12, - :graphicOpacity => 1, - :graphicXOffset => -6, - :graphicYOffset => -6, - :display => true + label: "${label}", + fontColor: "black", + fontSize: "14px", + fontWeight: "bold", + labelAlign: "ct", + labelXOffset: 0, + labelYOffset: -15, + strokeColor: "#000000", + strokeOpacity: 1, + strokeWidth: 3, + strokeLineCap: "round", + strokeDashstyle: "solid", + externalGraphic: @helpers.assets_path_patch( "map/${positionType}.png"), + graphicWidth: 12, + graphicHeight: 12, + graphicOpacity: 1, + graphicXOffset: -6, + graphicYOffset: -6, + display: true } end def context - context = { - :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", - :positionType => :" function(feature) { if (feature.attributes.iconCode != undefined) {return feature.attributes.iconCode;} else { return '';} } " + { + label: :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", + positionType: :" function(feature) { if (feature.attributes.iconCode != undefined) {return feature.attributes.iconCode;} else { return '';} } " } end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), :select => OpenLayers::Style.new(style.merge( select_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 diff --git a/app/maps/journey_pattern_map.rb b/app/maps/journey_pattern_map.rb index e5eaa7f6b..9a0da5743 100644 --- a/app/maps/journey_pattern_map.rb +++ b/app/maps/journey_pattern_map.rb @@ -8,14 +8,12 @@ class JourneyPatternMap < ApplicationMap end def customize_map(map, page) - layer = kml_layer([journey_pattern.referential, journey_pattern.route.line, journey_pattern.route, journey_pattern], :styleMap => Design::JourneyPatternStyleMap.new(helpers).style_map) - page.assign "journeyPatternLayer", layer + layer = kml_layer([journey_pattern.referential, journey_pattern.route.line, journey_pattern.route, journey_pattern], { setLayerIndex: 999, styleMap: Design::JourneyPatternStyleMap.new(helpers).style_map, rendererOptions: { zIndexing: true } }) + page.assign 'journeyPatternLayer', layer + page.assign 'selectFeature', OpenLayers::Control::SelectFeature.new(:journeyPatternLayer) - selectFeature = OpenLayers::Control::SelectFeature.new( :journeyPatternLayer) - page.assign "selectFeature", selectFeature - - page << map.add_layer( :journeyPatternLayer) - page << map.add_control( hover_control_display_name(:journeyPatternLayer) ) + page << map.add_layer(:journeyPatternLayer) + page << map.add_control(hover_control_display_name(:journeyPatternLayer)) page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds end diff --git a/app/maps/route_map.rb b/app/maps/route_map.rb index 5acb1ad76..bdd6c4a56 100644 --- a/app/maps/route_map.rb +++ b/app/maps/route_map.rb @@ -8,7 +8,7 @@ class RouteMap < ApplicationMap end def customize_map(map, page) - layer = kml_layer([route.referential, route.line, route], :styleMap => Design::RouteStyleMap.new(helpers).style_map) + layer = kml_layer([route.referential, route.line, route], :styleMap => Design::RouteStyleMap.new(helpers, {context: context = {label: ""}}).style_map) page.assign "routeLayer", layer selectFeature = OpenLayers::Control::SelectFeature.new( :routeLayer) |
