[OpenLayers-Dev] Get resulting bounding box from TouchNavigation

Bessette-Halsema, Dominique E Dominique.Bessette at GDIT.com
Mon Oct 15 14:01:00 PDT 2012


I would just like to note I got the bounds using the below method:
Where

bounds.left: west
bounds.bottom: south
bounds.right: east
bounds.top: north


private static native void createBoxControl(MapView scope, boolean activateBoxCtrl) /*-{
                $wnd.boxControl = new $wnd.OpenLayers.Control.Navigation({'zoomWheelEnabled': true});

                        function notice() {
                        var EPSG4326 = new $wnd.OpenLayers.Projection("EPSG:4326");
                                var origBounds = $wnd.map.getExtent();
                                var bounds = origBounds.transform($wnd.map.getProjectionObject(), EPSG4326);

                scope. at mil.navy.fnmoc.gis.mapss.selection.client.MapView::updateCorners(DDDD)(
                                    bounds.left, bounds.bottom, bounds.right, bounds.top);
            }

                $wnd.map.events.register("touchend",$wnd.boxControl, notice);

        }-*/;

-----Original Message-----
From: andreas.hocevar at gmail.com [mailto:andreas.hocevar at gmail.com] On Behalf Of Andreas Hocevar
Sent: Tuesday, October 09, 2012 8:55 AM
To: Bessette-Halsema, Dominique E
Cc: openlayers-dev at lists.osgeo.org
Subject: Re: [OpenLayers-Dev] Get resulting bounding box from TouchNavigation

The easiest to achieve this is to register for the map's zoomend event:

    function notice() {
        var bounds = map.getExtent();
        /* your existing notice code here */
    }
    map.events.register("zoomend", this, notice);

Andreas.

On Tue, Oct 9, 2012 at 12:25 AM, Bessette-Halsema, Dominique E <Dominique.Bessette at gdit.com> wrote:
> Hi
>
> I'm having issues creating handlers for my mobile touch map.  Using TouchNavigation I'm able to Pan and PinchZoom but I need the resulting bounding box from the map.  If you look at the old Non-mobile code below I need to be able to call the notice function when the user is done panning and zooming.  Is there a way I can do this?
>
> TouchNavigation code
>
> private static native void createBoxControl(MapView scope, boolean activateBoxCtrl) /*-{
>     $wnd.boxControl = new $wnd.OpenLayers.Control.TouchNavigation({
>             dragPanOptions: {
>                 interval: 0, // non-zero kills performance on some mobile phones
>                 enableKinetic: true
>             }
>         })
>
>
> }-*/;
>
>
>
> Old Non-Mobile code
>
> private static native void createBoxControl(MapView scope, boolean activateBoxCtrl) /*-{
>         $wnd.boxControl = new $wnd.OpenLayers.Control();
>         $wnd.OpenLayers.Util.extend($wnd.boxControl, {
>             draw: function() {
>                 this.handler = new $wnd.OpenLayers.Handler.Box($wnd.boxControl,
>                     {"done": this.notice},
>                     {keyMask: $wnd.OpenLayers.Handler.MOD_SHIFT});
>                 if(activateBoxCtrl) {
>                     this.activate();
>                 }
>             },
>
>             notice: function(bounds) {
>                 var leftBottomPx = new $wnd.OpenLayers.Pixel(bounds.left, bounds.bottom);
>                 var rightTopPx = new $wnd.OpenLayers.Pixel(bounds.right, bounds.top);
>                 var leftBottomLonLat = $wnd.map.getLonLatFromViewPortPx(leftBottomPx);
>                 var rightTopLonLat = $wnd.map.getLonLatFromViewPortPx(rightTopPx);
>                 scope. at mil.navy.fnmoc.gis.mapss.selection.client.MapView::updateCorners(DDDD)(
>                     leftBottomLonLat.lon, leftBottomLonLat.lat, rightTopLonLat.lon, rightTopLonLat.lat);
>             }
>         });
>     }-*/;
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Dev mailing list