Reflect any changes made to the bounds in the map.

This commit is contained in:
Tom Hughes 2008-04-09 18:14:30 +00:00
parent f1c0834c5c
commit 2c66491e00

View file

@ -43,13 +43,15 @@
<script type="text/javascript">
<!--
var box;
function startExport() {
var vectors = new OpenLayers.Layer.Vector("Vector Layer", {
displayInLayerSwitcher: false,
});
map.addLayer(vectors);
var box = new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.RegularPolygon, {
box = new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.RegularPolygon, {
handlerOptions: {
keyMask: OpenLayers.Handler.MOD_CTRL,
sides: 4,
@ -88,6 +90,29 @@
$("export_format_pdf").onclick = function() { formatChanged() };
$("export_format_svg").onclick = function() { formatChanged() };
function boundsChanged() {
var epsg4326 = new OpenLayers.Projection("EPSG:4326");
var bounds = new OpenLayers.Bounds($("export_minlon").value,
$("export_minlat").value,
$("export_maxlon").value,
$("export_maxlat").value);
bounds.transform(epsg4326, map.getProjectionObject());
map.events.unregister("moveend", map, mapMoved);
map.zoomToExtent(bounds);
box.handler.clear();
box.handler.feature = new OpenLayers.Feature.Vector(bounds.toGeometry());
box.handler.layer.addFeatures([box.handler.feature], [box.handler.style]);
box.handler.layer.drawFeature(box.handler.feature, box.handler.style);
}
$("export_maxlat").onchange = function() { boundsChanged() };
$("export_minlon").onchange = function() { boundsChanged() };
$("export_maxlon").onchange = function() { boundsChanged() };
$("export_minlat").onchange = function() { boundsChanged() };
function mapMoved() {
updateRegion(map.getExtent());
}