+ function style_function_selected(feature, resolution) {
+ if (feature.getGeometry() instanceof ol.geom.Point) return style_point_function_selected(feature, resolution);
+ return style_path_function(feature, resolution);
+ };
+
+
+ // popup overlay
+ // -------------
+ var popup_container = document.getElementById('popup');
+ var popup_content = document.getElementById('popup-content');
+ var popup_closer = document.getElementById('popup-closer');
+ var popup_overlay = new ol.Overlay({element: popup_container, autoPan: {animation: {duration: 250}}});
+ popup_closer.onclick = function() {popup_overlay.setPosition(undefined); popup_closer.blur(); return false;};
+
+ function create_popup_dom(feature) {
+ var popup_div = createElement('div');
+
+ // name
+ if (feature.get('name') !== undefined && (feature.get('wiki') !== undefined || feature.get('thumb_url') !== undefined)) {
+ var h2 = appendElement(popup_div, 'h2');
+ if (feature.get('wiki') === undefined) h2.text(feature.get('name'));
+ else appendElement(h2, 'a', {href: feature.get('wiki')}).text(feature.get('name'));
+ }
+
+ // sledrun information
+ if (feature.get('type') == 'sledrun') {
+ var p = appendElement(popup_div, 'p').text('Rodelbahnzustand').append(createElement('br'));
+ if (feature.get('condition') !== undefined) {
+ var condition_text = {1: 'Sehr gut', 2: 'Gut', 3: 'Mittelmäßig', 4: 'Schlecht', 5: 'Geht nicht'};
+ var year_month_day = feature.get('date_report').split('-');
+ p.append(createElement('a', {href: feature.get('wiki') + '#Eintr.C3.A4ge'}).text(condition_text[feature.get('condition')]), ' ');
+ p.append(createElement('small').text(year_month_day[2] + '.' + year_month_day[1] + '.'), ' ');
+ p.append(createElement('em').append(createElement('a', {href: feature.get('wiki') + '#Eintragen'}).text('Neu')));
+ } else {
+ p.append(createElement('em').append(createElement('a', {href: feature.get('wiki') + '#Eintragen'}).text('Bitte eintragen')));
+ }
+ }
+
+ // wiki link
+ if (feature.get('wiki') !== undefined) {
+ var a = appendElement(appendElement(popup_div, 'p'), 'a', {href: feature.get('wiki')});
+ var detail_text = 'Details';
+ if (feature.get('type') == 'sledrun') detail_text += ' zur Rodelbahn';
+ if (feature.get('type') == 'gasthaus') detail_text += ' zum Gasthaus';
+ if (feature.get('thumb_url') === undefined) a.text(detail_text);
+ else a.append(createElement('img', {src: feature.get('thumb_url'), alt: detail_text, title: detail_text}));
+ }
+
+ return popup_div;
+ }
+
+
+ /*
+ // point layer
+ // -----------
+ var filter_point_sledrun = new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: 'type',
+ value: 'sledrun'
+ });
+
+
+ var layer_point = new OpenLayers.Layer.Vector("Point", {
+ styleMap: new OpenLayers.StyleMap({
+ 'default': new OpenLayers.Style({
+ graphicZIndex: 12,
+ backgroundGraphicZIndex: 11,
+ }, {
+ context: {
+ // the following context functions should only be available in the rule that uses them,
+ // but the rule dependent contexts are ignored by OpenLayers (I think that's a bug)
+ getCondition: get_sledrun_condition,
+ getSymbol: function(feature) {
+ var name = feature.attributes.type;
+ return name;
+ }
+ },
+ rules: [
+ new OpenLayers.Rule({
+ filter: filter_point_sledrun,
+ symbolizer: {
+ externalGraphic: img_path + '/marker_c_sledrun_${getCondition}nn.png',
+ graphicWidth: 17,
+ graphicHeight: 17,
+ graphicXOffset: -8,
+ graphicYOffset: -8,
+ backgroundGraphic: img_path + '/marker_c_shadow.png',
+ backgroundWidth: 23,
+ backgroundHeight: 23,
+ backgroundXOffset: -8,
+ backgroundYOffset: -8,
+ }
+ }),
+ new OpenLayers.Rule({
+ elseFilter: true,
+ symbolizer: {
+ externalGraphic: img_path + '/marker_p_${getSymbol}.png',
+ graphicWidth: 20,
+ graphicHeight: 34,
+ graphicXOffset: -10,
+ graphicYOffset: -33,
+ }
+ })
+ ]
+ }),
+ highlight: new OpenLayers.Style({
+ label: "${getTitle}",
+ labelOutlineColor: "white",
+ fontWeight: "bold"
+ }, {
+ context: {
+ getCondition: get_sledrun_condition,
+ getTitle: function(feature) {
+ var title = '';
+ if (feature.attributes.type != 'point') {
+ title = feature.attributes.type;
+ title = title.charAt(0).toUpperCase() + title.slice(1); // First letter uppercase
+ if (feature.attributes.name !== undefined) title += ': ';
+ }
+ if (feature.attributes.name !== undefined) title += feature.attributes.name;
+ return title;
+ }
+ },
+ rules: [
+ new OpenLayers.Rule({
+ filter: filter_point_sledrun,
+ symbolizer: {
+ label: "${name}",
+ labelYOffset: 14,
+ externalGraphic: img_path + '/marker_c_sledrun_${getCondition}nh.png'
+ }
+ }),
+ new OpenLayers.Rule({
+ elseFilter: true,
+ symbolizer: {
+ labelYOffset: 40
+ }
+ })
+ ]
+ }),
+ select: new OpenLayers.Style({
+ fillOpacity: 1.
+ }, {
+ context: {
+ getCondition: get_sledrun_condition,
+ },
+ rules: [
+ new OpenLayers.Rule({
+ filter: filter_point_sledrun,
+ symbolizer: {
+ externalGraphic: img_path + '/marker_c_sledrun_${getCondition}nh.png',
+ backgroundGraphic: false,
+ graphicXOffset: -6,
+ graphicYOffset: -6
+ }
+ }),
+ new OpenLayers.Rule({
+ elseFilter: true
+ })
+ ]
+ })