summaryrefslogtreecommitdiff
path: root/templates/gis/admin/openlayers.html
blob: f4efdcc26f0237f3f3b8213af07423e83fe725e9 (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
{% block extrastyle %}
<script>
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var lat = position.coords.latitude;
    var lon = position.coords.longitude;
    var proj = new OpenLayers.Projection("EPSG:4326");
    var point = new OpenLayers.LonLat(lon, lat);
    var wkt = point.transform(proj, geodjango_point.map.getProjectionObject());
    var wkttemp = "SRID=3857;POINT(" + wkt.lon + " "+ wkt.lat + ")";
    geodjango_point.map.setCenter(wkt);
    var admin_geom = geodjango_point.read_wkt(wkttemp);
    geodjango_point.layers.vector.addFeatures([admin_geom]);
  };

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  };


  navigator.geolocation.getCurrentPosition(success, error);
}
</script>
{% load static %}
<style type="text/css">
  #{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; }
  #{{ id }}_map .aligned label { float:inherit; }
  #{{ id }}_admin_map { position: relative; vertical-align: top; float: {{ LANGUAGE_BIDI|yesno:"right,left" }}; }
  {% if not display_wkt %}#{{ id }} { display: none; }{% endif %}
  .olControlEditingToolbar .olControlModifyFeatureItemActive { 
     background-image: url("{% static "admin/img/gis/move_vertex_on.png" %}");
     background-repeat: no-repeat;
  }
  .olControlEditingToolbar .olControlModifyFeatureItemInactive { 
     background-image: url("{% static "admin/img/gis/move_vertex_off.png" %}");
     background-repeat: no-repeat;
  }
</style>
<!--[if IE]>
<style type="text/css">
  /* This fixes the mouse offset issues in IE. */
  #{{ id }}_admin_map { position: static; vertical-align: top; }
  /* `font-size: 0` fixes the 1px border between tiles, but borks LayerSwitcher.
      Thus, this is disabled until a better fix is found.
  #{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; font-size: 0; } */
</style>
<![endif]-->
{% endblock %}
<span id="{{ id }}_admin_map">
<script type="text/javascript">
//<![CDATA[
{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
//]]>
</script>
<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
<div id="out"></div>
<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
<textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ name }}">{{ wkt }}</textarea>
<script type="text/javascript">{% block init_function %}{{ module }}.init();{% endblock %}</script>
</span>