Hi,<div><br></div><div>Since you are using GWT it would make sense to use GWT-OpenLayers: <a href="http://sourceforge.net/projects/gwt-openlayers/">http://sourceforge.net/projects/gwt-openlayers</a></div><div><br></div><div>
You can then do the same thing with Java code instead of inlining "native" code:</div><div><div><br></div><div>        map.addMapZoomListener(new MapZoomListener() {</div><div>            public void onMapZoom(MapZoomEvent eventObject) {</div>
<div>                Bounds bounds = eventObject.getSource().getExtent();</div><div>                // Your code here</div><div>            }</div><div>        });</div></div><div><br></div><div>That way you can debug in the Java code instead of having to debug JavaScript. Maybe that will make it easier for you to find out what is going on.</div>
<div><br></div><div>Regards,</div><div>Tim</div><div><br clear="all">Tim-Hinnerk Heuer<br><br>Twitter: @geekdenz<br><div>Blog: <a href="http://www.thheuer.com/" target="_blank">http://www.thheuer.com</a></div><br>
<br><br><div class="gmail_quote">On 11 October 2012 04:58, Bessette-Halsema, Dominique E <span dir="ltr"><<a href="mailto:Dominique.Bessette@gdit.com" target="_blank">Dominique.Bessette@gdit.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
Sorry I'm new to openlayers and javascript<br>
<br>
I'm still having trouble getting the correct lat/lon bounding box when I zoom in.  I'm registering the map but I cant seem to get the correct bounds.<br>
<br>
I'm using<br>
$wnd.boxControl = new $wnd.OpenLayers.Control.TouchNavigation();<br>
<br>
<br>
<br>
Javascript:<br>
    /**<br>
     * Creates the OpenLayers map.<br>
     * @param mapDiv the {@code div} element to put the map in<br>
     */<br>
    private static native void createMap(Element mapDiv,MapView scope) /*-{<br>
        var options = {<br>
            'restrictedExtent': new $wnd.OpenLayers.Bounds(-360.0, -90.0, 360.0, 90.0),<br>
            'projection': 'EPSG:4326',<br>
            'displayProjection': 'EPSG:4326',<br>
            'maxResolution': 'auto',<br>
            'maxExtent': new $wnd.OpenLayers.Bounds(-180.0, -90.0, 180.0, 90.0),<br>
            'maxZoomLevel': 16,<br>
            'numZoomLevels': 16,<br>
            'units': 'degrees',<br>
            'fractionalZoom': false,<br>
            'controls': [],<br>
            'theme': null<br>
        };<br>
        $wnd.map = new $wnd.OpenLayers.Map(mapDiv, options);<br>
        $wnd.map.addLayers([$wnd.worldLayer, $wnd.aoiBoxes]);<br>
<br>
         function notice() {<br>
                        var EPSG4326 = new $wnd.OpenLayers.Projection("EPSG:4326");<br>
                                var EPSG900913 = new $wnd.OpenLayers.Projection("EPSG:900913");<br>
                                var bounds = $wnd.map.getExtent().clone();<br>
                                bounds = bounds.transform(EPSG900913, EPSG4326);<br>
//              var bounds = $wnd.map.getExtent().transform($wnd.map.projection, $wnd.map.displayProjection);<br>
<div class="im">                var leftBottomPx = new $wnd.OpenLayers.Pixel(bounds.left, bounds.bottom);<br>
                var rightTopPx = new $wnd.OpenLayers.Pixel(bounds.right, bounds.top);<br>
                var leftBottomLonLat = $wnd.map.getLonLatFromViewPortPx(leftBottomPx);<br>
                var rightTopLonLat = $wnd.map.getLonLatFromViewPortPx(rightTopPx);<br>
                scope.@mil.navy.fnmoc.gis.mapss.selection.client.MapView::updateCorners(DDDD)(<br>
                    leftBottomLonLat.lon, leftBottomLonLat.lat, rightTopLonLat.lon, rightTopLonLat.lat);<br>
            }<br>
</div>        $wnd.map.events.register("zoomend", $wnd.map, notice);<br>
<br>
<br>
    }-*/;<br>
<br>
<br>
<br>
Java:<br>
<br>
/**<br>
     * Updates the corners of the AOI bounding box in the corner text boxes.<br>
     * @param minLon the new minimum longitude<br>
     * @param minLat the new minimum latitude<br>
     * @param maxLon the new maximum longitude<br>
     * @param maxLat the new maximum latitude<br>
     */<br>
    private void updateCornerBoxes(double minLon, double minLat, double maxLon, double maxLat) {<br>
         LOGGER.log(Level.FINE, "Update Corners "+minLon + " "+minLat + " " + maxLon + " "+ maxLat);<br>
        this.southNumberField.setValue(clampLatitude(minLat));<br>
        this.northNumberField.setValue(clampLatitude(maxLat));<br>
        wrapLongitudes(minLon, maxLon);<br>
<div class="HOEnZb"><div class="h5">    }<br>
<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:andreas.hocevar@gmail.com">andreas.hocevar@gmail.com</a> [mailto:<a href="mailto:andreas.hocevar@gmail.com">andreas.hocevar@gmail.com</a>] On Behalf Of Andreas Hocevar<br>
Sent: Tuesday, October 09, 2012 8:55 AM<br>
To: Bessette-Halsema, Dominique E<br>
Cc: <a href="mailto:openlayers-dev@lists.osgeo.org">openlayers-dev@lists.osgeo.org</a><br>
Subject: Re: [OpenLayers-Dev] Get resulting bounding box from TouchNavigation<br>
<br>
The easiest to achieve this is to register for the map's zoomend event:<br>
<br>
    function notice() {<br>
        var bounds = map.getExtent();<br>
        /* your existing notice code here */<br>
    }<br>
    map.events.register("zoomend", this, notice);<br>
<br>
Andreas.<br>
<br>
On Tue, Oct 9, 2012 at 12:25 AM, Bessette-Halsema, Dominique E <<a href="mailto:Dominique.Bessette@gdit.com">Dominique.Bessette@gdit.com</a>> wrote:<br>
> Hi<br>
><br>
> 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?<br>

><br>
> TouchNavigation code<br>
><br>
> private static native void createBoxControl(MapView scope, boolean activateBoxCtrl) /*-{<br>
>     $wnd.boxControl = new $wnd.OpenLayers.Control.TouchNavigation({<br>
>             dragPanOptions: {<br>
>                 interval: 0, // non-zero kills performance on some mobile phones<br>
>                 enableKinetic: true<br>
>             }<br>
>         })<br>
><br>
><br>
> }-*/;<br>
><br>
><br>
><br>
> Old Non-Mobile code<br>
><br>
> private static native void createBoxControl(MapView scope, boolean activateBoxCtrl) /*-{<br>
>         $wnd.boxControl = new $wnd.OpenLayers.Control();<br>
>         $wnd.OpenLayers.Util.extend($wnd.boxControl, {<br>
>             draw: function() {<br>
>                 this.handler = new $wnd.OpenLayers.Handler.Box($wnd.boxControl,<br>
>                     {"done": this.notice},<br>
>                     {keyMask: $wnd.OpenLayers.Handler.MOD_SHIFT});<br>
>                 if(activateBoxCtrl) {<br>
>                     this.activate();<br>
>                 }<br>
>             },<br>
><br>
>             notice: function(bounds) {<br>
>                 var leftBottomPx = new $wnd.OpenLayers.Pixel(bounds.left, bounds.bottom);<br>
>                 var rightTopPx = new $wnd.OpenLayers.Pixel(bounds.right, bounds.top);<br>
>                 var leftBottomLonLat = $wnd.map.getLonLatFromViewPortPx(leftBottomPx);<br>
>                 var rightTopLonLat = $wnd.map.getLonLatFromViewPortPx(rightTopPx);<br>
>                 scope.@mil.navy.fnmoc.gis.mapss.selection.client.MapView::updateCorners(DDDD)(<br>
>                     leftBottomLonLat.lon, leftBottomLonLat.lat, rightTopLonLat.lon, rightTopLonLat.lat);<br>
>             }<br>
>         });<br>
>     }-*/;<br>
> _______________________________________________<br>
> Dev mailing list<br>
> <a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
<br>
<br>
<br>
--<br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
<br>
_______________________________________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org">Dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-dev</a><br>
</div></div></blockquote></div><br></div>