Ticket #13117: widget.diff

File widget.diff, 2.0 KB (added by nbv4, 14 years ago)

center GeoModelAdmin widget

  • contrib/gis/templates/gis/admin/openlayers.html

     
    2929{% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %}
    3030//]]>
    3131</script>
     32<div id="{{module}}_recenter">
     33<label for="{{module}}_lat">Lattitude:</label><input class="{{module}}_lat" type="text"><br>
     34<label for="{{module}}_lng">Longitude:</label><input class="{{module}}_lng" type="text">
     35<input type="button" class="{{module}}_recenter" value="Recenter" />
     36</div>
    3237<div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div>
    3338<a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a>
    3439{% if display_wkt %}<p> WKT debugging window:</p>{% endif %}
  • contrib/gis/templates/gis/admin/openlayers.js

     
    158158      {{ module }}.enableDrawing();
    159159    }
    160160}
     161
     162jQuery(document).ready(function() {
     163
     164    jQuery("input.{{module}}_recenter").click(function() {
     165        // when the button is clicked, re-center the
     166        // map to the entered coordinates
     167       
     168        //get coordinates from the text boxes
     169        var lat = jQuery("input.{{module}}_lat").val();
     170        var lng = jQuery("input.{{module}}_lng").val();
     171       
     172        // create two projection objects
     173        // lat/lng (EPSG:4326)
     174        // and the current one (EPSG:900913)
     175        var latlng_proj = new OpenLayers.Projection("EPSG:4326");
     176        var this_proj = {{ module }}.map.projection;
     177       
     178        // convert
     179        ll = new OpenLayers.LonLat(lng, lat);
     180        ll.transform(latlng_proj, this_proj);
     181       
     182        // now re-center
     183        {{ module }}.map.setCenter(ll);
     184    });
     185   
     186});
Back to Top