{% extends "lizard_map/lizardgis.html" %}
{% load i18n map workspaces %}


{% block map-javascript %}
  {% if view.has_google %}
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key={{ view.map_variables.googlemaps_api_key }}"></script>
  {% endif %}
{% endblock map-javascript %}


{% block secondary-sidebar %}
  {% animation_control_panel view.workspace_edit %}
  {% workspace_edit view.workspace_edit %}
  {% collage_edit view.collage_edit %}
{% endblock secondary-sidebar %}

{% block rightbar %}
  <h2>{% trans "Legend" %}</h2>
  {% for legend in view.legends %}
    {{ legend.to_html }}
  {% endfor %}
{% endblock rightbar %}


{% block content %}
  {# data attributes wms #}
  {# All contents of lizard-map-wms must have class lizard-map-wms-item #}
  <div id="lizard-map-wms"
       data-javascript-click-handler="{{ view.javascript_click_handler }}"
       {% if view.javascript_hover_handler %}
         {% ifnotequal view.javascript_hover_handler 'None' %}
         data-javascript-hover-handler="{{ view.javascript_hover_handler }}"
         {% endifnotequal %}
       {% endif %}
       {# New style maps #}
       data-max-extent-left="{{ view.max_extent.left }}"
       data-max-extent-top="{{ view.max_extent.top }}"
       data-max-extent-right="{{ view.max_extent.right }}"
       data-max-extent-bottom="{{ view.max_extent.bottom }}"
       data-start-extent-left="{{ view.start_extent.left }}"
       data-start-extent-top="{{ view.start_extent.top }}"
       data-start-extent-right="{{ view.start_extent.right }}"
       data-start-extent-bottom="{{ view.start_extent.bottom }}"
       {# for WMS: EPSG:28992, EPSG:900913 #}
       data-projection="{{ view.projection }}"
       {# for WMS: EPSG:28992, EPSG:900913, EPSG:4326 #}
       data-display-projection="{{ view.display_projection }}"
       {# URLS for saving, loading map locations #}
       data-save-location-url="{% url lizard_map.map_location_save %}"
       data-load-location-url="{% url lizard_map.map_location_load_default %}"
       {# Selected base layer #}
       data-selected-base-layer="{{ view.base_layer_name }}"
       >
    {# Make a layer for every background map #}
    {% for background_map in view.background_maps %}
      {% background_map background_map %}
    {% endfor %}
    {# Add wms layers from workspace #}
    {% for wms_layer in view.wms_layers %}
      {% autoescape off %}
        <div class="workspace-wms-layer lizard-map-wms-item"
             data-workspace-wms-id="{{ wms_layer.wms_id }}"
             data-workspace-wms-name="{{ wms_layer.name }}"
             data-workspace-wms-url="{{ wms_layer.url }}"
             {# json uses "" #}
             data-workspace-wms-params='{{ wms_layer.params }}'
             data-workspace-wms-options='{{ wms_layer.options }}'
             data-workspace-wms-index='{{ wms_layer.index }}'
             data-workspace-wms-animatable='{{ wms_layer.is_animatable }}'>
         </div>
       {% endautoescape %}
     {% endfor %}
  </div>
  <div id="map"></div>
{% endblock content %}
