[Users] WMS capabilities tree with Google base map v2 /v3

Jason Woolard Jason.Woolard at noaa.gov
Wed Nov 16 18:14:57 CET 2011


hi,

I'm loading a WMS capabilities doc in a tree view with a Google base 
layer. The remote WMS is only available in 4326. With the Google v2 api 
this works just fine and I can verify in the url the requests are in 4326.

var tree;
var mapPanel;
var map;
var lon = -88.39;
var lat = 30.25;

Ext.onReady(function() {
        mapPanel= new GeoExt.MapPanel({
             zoom: 7,
             layers: [new OpenLayers.Layer.Google(
                 "Google Streets" )
             ],
             center: new OpenLayers.LonLat(lon,lat),
             region: 'center'
         });

     var root = new Ext.tree.AsyncTreeNode({
         text: 'Layers',
         loader: new GeoExt.tree.WMSCapabilitiesLoader({
             url: 
'http://localhost:8080/geoserver/rest/proxy?url=http://hdds.usgs.gov/ArcGIS/services/201004_OilSpill_GulfOfMexico/MapServer/WMSServer?request=GetCapabilities',
             layerOptions: {buffer: 0, singleTile: true, ratio: 1},
             layerParams: {'TRANSPARENT': 'TRUE'},
             // customize the createNode method to add a checkbox to nodes
             createNode: function(attr) {
                 attr.checked = attr.leaf ? false : undefined;
                 return 
GeoExt.tree.WMSCapabilitiesLoader.prototype.createNode.apply(this, [attr]);
             }
         })
     });

tree = new Ext.tree.TreePanel({.......
});

new Ext.Viewport({ .........
});


When changing to the v3 api and making what I think are the necessary 
changes I can only get the requests in 900913 which obviously return 
pink tiles since it's a unsupported projection.

With v3 I'm setting up the map like this:

var options = {
         projection: new OpenLayers.Projection("EPSG:900913"),
         displayProjection: new OpenLayers.Projection("EPSG:4326"),
         units: "m",
         numZoomLevels: 20,
         maxResolution: 156543.0339,
         maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 
20037508, 20037508.34),
         controls: [new OpenLayers.Control.Navigation(), new 
OpenLayers.Control.PanZoomBar(),
                     new OpenLayers.Control.MouseDefaults()]
       };
       map = new OpenLayers.Map('map', options);
       var gmap = new OpenLayers.Layer.Google(
             "Google Streets"
       );

       map.addLayer(gmap);
       map.setCenter(new OpenLayers.LonLat(lon,lat).transform(
             new OpenLayers.Projection("EPSG:4326"),
             map.getProjectionObject()), 7);

     mapPanel= new GeoExt.MapPanel({
             map: map,
             center: new OpenLayers.LonLat(lon, lat).transform(new 
OpenLayers.Projection("EPSG:4326"),
                        new OpenLayers.Projection("EPSG:900913"),7),
             region: 'center'
         });

Am I handling this the wrong way in the v3 api or is this functionality 
that no longer exists and now a projection needs to be performed on the fly?

Thanks in advance.


More information about the Users mailing list