[OpenLayers-Dev] Get resulting bounding box from TouchNavigation

Bessette-Halsema, Dominique E Dominique.Bessette at GDIT.com
Mon Oct 8 15:25:47 PDT 2012


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);
            }
        });
    }-*/;


More information about the Dev mailing list