diff options
author | luxagraf <sng@luxagraf.net> | 2016-01-27 22:19:51 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2016-01-27 22:19:51 -0500 |
commit | 81f54d4d9b3edfd440f641aca5408362cefb8319 (patch) | |
tree | d785dd61ae7d11ffea86953b294f7c337c122861 /design/templates/gis/admin/openlayers.html | |
parent | ee448528f291199adc38c5316b71944ca07f6dc3 (diff) |
Added auto geolocation features to checkin
Diffstat (limited to 'design/templates/gis/admin/openlayers.html')
-rw-r--r-- | design/templates/gis/admin/openlayers.html | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/design/templates/gis/admin/openlayers.html b/design/templates/gis/admin/openlayers.html index a61b689..f4efdcc 100644 --- a/design/templates/gis/admin/openlayers.html +++ b/design/templates/gis/admin/openlayers.html @@ -1,4 +1,33 @@ {% 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; } @@ -31,6 +60,7 @@ //]]> </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> |