[OpenLayers-Users] Re: How to control OpenLayer's choice of BBOX request when straddling 180 degrees on Google Maps

Andrew Watkins a.watkins at niwa.co.nz
Wed Oct 19 16:40:53 EDT 2011


FOLLOW UP: cracked it.

Setting wrapDateLine:*false* in the Google map constructor is the key.  This
is counter intuitive.
var google_maps = new OpenLayers.Layer.Google("Google Terrain", {
          numZoomLevels: 20,
          sphericalMercator: true,
          type: google.maps.MapTypeId.TERRAIN,
          wrapDateLine:false
     }
);
google_maps.projection = WebMercator;		
map.addLayer(google_maps);

var niwa_stations = new OpenLayers.Layer.WFS("NIWA Stations",
sims_wfs_server,
        {typename: "stations" }, 
        {extractAttributes: true, wrapDateLine: true  }
        );
niwa_stations.projection = WGS84;
map.addLayer(niwa_stations);        


Google still sends tiles for the Pacific region and the WFS layer sends
points for the same, It all looks good but the map will no longer pan past
the date line.  

However then setting the maxExtent to 0..360 as well fixes that issue.
// this is my 0..360 equivalent of Google's default max extent.
var nz_world_m = new OpenLayers.Bounds(
        0 * 156543.03390625,
        -128 * 156543.03390625,
        256 * 156543.03390625,
        128 * 156543.03390625
    );

var google_maps = new OpenLayers.Layer.Google("Google Terrain", {
	   maxExtent: nz_world_m,   
...





--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-to-control-OpenLayer-s-choice-of-BBOX-request-when-straddling-180-degrees-on-Google-Maps-tp6907084p6910444.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list