summaryrefslogtreecommitdiff
path: root/templates/chimere/blocks/map.html
blob: 99880e9f70a7a456c7ec20b1ca16e3799c729562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{% load i18n %}
<div id='{{map_id}}'></div>
<div id='popup'></div>
<div id='layerSwitcher'></div>
<script type="text/javascript">
$("#{{map_id}}").show();
</script>
<div id="waiting">
    <div id="waiting-content">
        <img src='{{STATIC_URL}}chimere/img/ajax-loader.gif' alt='Ajax loader'/>
        <p>{% trans "Loading of the map in progress" %}</p>
    </div>
</div>

<div id="layer_selection">
  <h4>{% trans "Display options" %}</h4>
  <ul id='layer_list'>
    <li class='head layer_map_type'>{% trans "Map type"%}</li>
  </ul>
</div>


<script type="text/javascript">
    var routing_panel_open = function(){
        $('#frm_categories').hide();
        $('#search-box').hide();
        $('#chimere_itinerary_panel').show();
        $('#action-categories').removeClass('state-active');
        $('#action-search').removeClass('state-active');
        $('#action-routing').addClass('state-active');
    };

    $('#action-routing').click(routing_panel_open);

    var category_panel_open = function(){
        $('#chimere_itinerary_panel').hide();
        $('#search-box').hide();
        $('#frm_categories').show();
        $('#action-routing').removeClass('state-active');
        $('#action-search').removeClass('state-active');
        $('#action-categories').addClass('state-active');
    };

    $('#action-categories').click(category_panel_open);

    var search_panel_open = function(){
        $('#chimere_itinerary_panel').hide();
        $('#frm_categories').hide();
        $('#search-box').show();
        $('#action-routing').removeClass('state-active');
        $('#action-categories').removeClass('state-active');
        $('#action-search').addClass('state-active');
    };

    $('#action-search').click(search_panel_open);

    $('#sidebar-handler-hide').click(function(){$('#sidebar').hide();});
    $('#sidebar-handler-show').click(function(){$('#sidebar').show();});

    {% if single_category %}
    $(function() {$('#panel').hide()});{% endif %}
    var chimere_init_options = {
        {% if MOBILE %}"mobile": true,{% endif %}
        {% if enable_clustering %}"enable_clustering": true,{% endif %}
        "routing_panel_open": routing_panel_open,
        "category_accordion": false,
        "category_plus": STATIC_URL + "saclay/images/plus.png",
        "category_minus": STATIC_URL + "saclay/images/minus.png",
        "popupContentFull": true,
        "explicit_popup_hide": true,
        "map_layers": [{{js_map_layers|safe|escape}}],
        'permalink_label': '{%trans "Permalink"%}',
        'permalink_element': document.getElementById('permalink'),
        'routing': {{routing}},
        {% if dynamic_categories %}'dynamic_categories': true,{% endif %}
        {% if default_area %}"default_area": new Array({{default_area.upper_left_corner.x}}, {{default_area.upper_left_corner.y}}, {{default_area.lower_right_corner.x}}, {{default_area.lower_right_corner.y}}),{% endif %}
        {% if p_zoom %}"zoom": {{ p_zoom }},{% endif %}
        {% if p_lat %}"lat": {{ p_lat }},{% endif %}
        {% if p_lon %}"lon": {{ p_lon }},{% endif %}
        {% if p_routing_start_lon %}"routing_start_lon": {{ p_routing_start_lon }},{% endif %}
        {% if p_routing_start_lat %}"routing_start_lat": {{ p_routing_start_lat }},{% endif %}
        {% if p_routing_end_lon %}"routing_end_lon": {{ p_routing_end_lon }},{% endif %}
        {% if p_routing_end_lat %}"routing_end_lat": {{ p_routing_end_lat }},{% endif %}
        {% if p_routing_steps %}"routing_steps_lonlat": [{{ p_routing_steps }}],{% endif %}
        {% if p_routing_transport %}"routing_transport": "{{ p_routing_transport }}",{% endif %}
        {% if p_routing_speed %}"routing_speed": "{{ p_routing_speed }}",{% endif %}
        "dynamic_categories": {{ dynamic_categories }},
        {% if p_display_submited %}"display_submited": {{ p_display_submited }},{% endif %}
        "checked_categories": [{% for cc in checked_categories %}{% if forloop.counter0 > 0 %}, {% endif %}{{cc}}{% endfor %}],
        {% if area_id %}'area_id': "{{area_id}}",{% endif %}
        {% if p_current_feature %}"display_feature": {{ p_current_feature }},{% endif %}
        {% if selected_map_layer %}"selected_map_layer": {{selected_map_layer}},{% endif %}
        "display_feature_detail_callback": display_feature_detail_callback,
        "edition_type_is_route": true
    }
    {% if restricted_extent %}{{ restricted_extent }}
    chimere_init_options["restricted_extent"] = bounds;
    {% endif %}
    {% comment %}
    chimere_init_options["default_icon"] = new OpenLayers.Icon(
                    '{{STATIC_URL}}saclay/images/default_icon.png',
                    new OpenLayers.Size(37, 42),
                    new OpenLayers.Pixel(-(37/2), -42));
    chimere_init_options["icon_start"] = new OpenLayers.Icon(
                    '{{STATIC_URL}}saclay/images/routing_start.png',
                    new OpenLayers.Size(37, 42),
                    new OpenLayers.Pixel(-(37/2), -42));
    chimere_init_options["icon_end"] = new OpenLayers.Icon(
                    '{{STATIC_URL}}saclay/images/routing_end.png',
                    new OpenLayers.Size(37, 42),
                    new OpenLayers.Pixel(-(37/2), -42));
    chimere_init_options["icon_step"] = new OpenLayers.Icon(
                    '{{STATIC_URL}}saclay/images/routing_step.png',
                    new OpenLayers.Size(37, 42),
                    new OpenLayers.Pixel(-(37/2), -42));
    };
    var numZoomLevels = 7;
    var maxZoomLevel = 19;
    var resolutions;
    var zoomOffset;
    if (numZoomLevels && maxZoomLevel){
        // variables set to be used in layer definition
        var minZoomLevel = maxZoomLevel - numZoomLevels;
        resolutions =
                OpenLayers.Layer.Bing.prototype.serverResolutions.slice(
                         maxZoomLevel - numZoomLevels,
                         maxZoomLevel);
        zoomOffset = minZoomLevel;
    }

        "icon_offset": new OpenLayers.Pixel({{icon_offset_x}},
                                                                   {{icon_offset_y}}),
        'marker_hover_offset': new OpenLayers.Pixel(7, 20),
        "popupClass"].imageSrc = "{{STATIC_URL}}/saclay/js/cloud-popup-saclay.png",
        "cluster_icon": new OpenLayers.Icon(
                        STATIC_URL + "saclay/images/cluster_icon.png",
                        new OpenLayers.Size(39, 46),
                        new OpenLayers.Pixel(-(39/2), -(46/2))),
        //"display_feature_detail_fx": display_feature_detail,
    {% endcomment %}

    $("#{{map_id}}").chimere(chimere_init_options);
    {% if zoom %}
    $('#maps').chimere('zoom', {'area':{{zoom}} });
    {% endif %}

    // init layer selection
    $(function() {
        {% for layer_name, js, def in map_layers %}
        $('#layer_list').append("<li class='layer_map{% if def %} selected{%endif%}'><input type='radio' value='{{forloop.counter0}}' name='layer_type' id='layer_{{forloop.counter}}'{% if def %} checked='checked'{% endif %}><label for='layer_{{forloop.counter}}'>{{layer_name}}</li>");{% endfor %}
        {% for subcat in subcat_layer %}
        {% if not subcat.category %}
        $('#layer_list').append("<li class='head layer_category'>{{subcat.name}}</li>");{% else %}
        $('#layer_list').append("<li class='layer_subcat{% if subcat.pk in checked_categories %} selected{%endif%}'><input type='checkbox' name='layer_cat' value='category_{{subcat.pk}}' id='layer_cat_{{subcat.pk}}'{% if subcat.pk in checked_categories %} checked='checked'{% endif %}><label for='layer_cat_{{subcat.pk}}'>{{subcat.name}}</li>");{%endif%}{% endfor %}
        $('#layer_selection h4').click(function(){
            $('#layer_list').toggle();
            if ($('#layer_list').is(':visible')){
                $('#layer_selection h4').addClass('opened');
            } else {
                $('#layer_selection h4').removeClass('opened');
            }
        });
        $('#layer_list input[name=layer_type]').change(function(){
            $('#{{map_id}}').chimere('changeMapLayer', $(this).val());
            $('li.layer_map').removeClass('selected');
            $(this).parent().addClass('selected');
        });
        $('#layer_list input[name=layer_cat]').change(function(){
            // the prop has to be called twice not to mess up with the triggered
            // click
            $('#'+$(this).val()).prop("checked", this.checked);
            $('#'+$(this).val()).trigger('click');
            $('#'+$(this).val()).prop("checked", this.checked);
            if (this.checked){
                $(this).parent().addClass('selected');
            } else {
                $(this).parent().removeClass('selected');
            }
        });
    });
</script>
<div id='marker_hover'><div id='marker_hover_content'></div></div>
<div class="modal fade" id="cluster_list" tabindex="-1" role="dialog" aria-labelledby="cluster-label" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header modal-header-success">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="cluster-label">&nbsp;</h4>
      </div>
      <div class="modal-body">
      </div>
    </div>
  </div>
</div>