<span class="ul-threaded" style="margin: 0.5em 0pt 0pt -20px;"><span class="text-cell">Hello there,
<br><br>I am trying to use custom control to draw a rectangular box and
get the dimension after drawing a box on the map. My problem is I want
to retain the box on mouse up instead of the box disappearing. Right
now, it displays the alert box when I mouse up.
<br><br>Here is what I am doing now:
<br><br><code>
<br>var control = new OpenLayers.Control();
<br> OpenLayers.Util.extend(control, {
<br> draw: function () {
<br> // this Handler.Box will intercept the shift-mousedown
<br> // before Control.MouseDefault gets to see it
<br> this.box = new OpenLayers.Handler.Box( control,
<br> {"done": this.notice},
<br> {keyMask: OpenLayers.Handler.MOD_SHIFT});
<br> this.box.activate();
<br> },
<br><br> notice: function (bounds) {
<br> var ll = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.bottom));
<br> var ur = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.right, bounds.top));
<br> alert(ll.lon.toFixed(4) + ", " +
<br> ll.lat.toFixed(4) + ", " +
<br> ur.lon.toFixed(4) + ", " +
<br> ur.lat.toFixed(4));
<br> }
<br> });
<br> map.addControl(control);
<br><br></code>
<br><br>What I need is when I press shift key I should be able to draw a
box on the map and then resize it if required and then click a button
to get the dimensions(alert box).
<br><br>I appreciate any help,
<br>Thanks a lot!
<br>Moiz
</span></span>