[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH] Validate the size of the bounding box with java
From: |
Gaël Utard |
Subject: |
[Maposmatic-dev] [PATCH] Validate the size of the bounding box with javascript. |
Date: |
Wed, 4 Aug 2010 19:04:24 +0200 |
Signed-off-by: Gaël Utard <address@hidden>
---
www/media/osm_map.js | 18 ++++++++++++++++++
www/templates/maposmatic/new.html | 3 +++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/www/media/osm_map.js b/www/media/osm_map.js
index f3f6bc1..a81e89d 100644
--- a/www/media/osm_map.js
+++ b/www/media/osm_map.js
@@ -52,6 +52,24 @@ function updateFormBbox(bounds)
getUpperLeftLon().value = bounds.left.toFixed(4);
getBottomRightLat().value = bounds.bottom.toFixed(4);
getBottomRightLon().value = bounds.right.toFixed(4);
+
+ p1 = new OpenLayers.LonLat(bounds.left, bounds.top);
+ p2 = new OpenLayers.LonLat(bounds.right, bounds.top);
+ p3 = new OpenLayers.LonLat(bounds.right, bounds.bottom);
+
+ dist1 = OpenLayers.Util.distVincenty(p1, p2)
+ dist2 = OpenLayers.Util.distVincenty(p2, p3)
+
+ if (dist1 > 20 || dist2 > 20)
+ {
+ document.getElementById('bboxtoolarge').style.display = 'block'
+ document.getElementById('id_go_next_btn').disabled = true
+ }
+ else
+ {
+ document.getElementById('bboxtoolarge').style.display = 'none'
+ document.getElementById('id_go_next_btn').disabled = false
+ }
}
/* Update the map on form field modification. */
diff --git a/www/templates/maposmatic/new.html
b/www/templates/maposmatic/new.html
index a883598..0da89f8 100644
--- a/www/templates/maposmatic/new.html
+++ b/www/templates/maposmatic/new.html
@@ -94,6 +94,9 @@ map.{% endblocktrans %}
<tr class="bybbox field"><td colspan="2">
{{ form.bbox }}
{{ form.bbox.errors }}
+ <ul class="errorlist" id="bboxtoolarge" style="display: none">
+ <li>{% blocktrans %}Bounding Box too large{% endblocktrans %}</li>
+ </ul>
<p class="bbox_select_help">{% blocktrans %}Latitude and longitude of
the top left and bottom right corners of the area to render.{% endblocktrans
%}</p>
<p class="bbox_select_help">{% blocktrans %}You can use
<tt>Shift+drag</tt> to zoom on a specific area of the map. You can use
<tt>Control+drag</tt> to draw the limits of the area to render.{% endblocktrans
%}</p>
</td></tr>
--
1.7.0.4
- [Maposmatic-dev] [PATCH] Validate the size of the bounding box with javascript.,
Gaël Utard <=