|
From: John P. <byh...@gm...> - 2011-02-06 14:46:17
|
Hi All, I have a gwt-openlayers application working well overlaying
multiple wms layers
(mapOptions.setAllOverlays(true)), each with a different projection, and setting
the map projection to my local projection (EPSG:24200). Now I want to be able to
add a google maps layer as another layer to use, but when I load it I
get an image
of the world spead out about 4 times, side by side. The code I'm using is below:
// ========================================================================= //
// Defining a WMS and adding it to the map
WMSParams wmsParams = new WMSParams();
wmsParams.setFormat("image/png");
wmsParams.setLayers("WMSLayer1");
wmsParams.setIsTransparent(true);
wmsParams.setStyles("");
WMSOptions wmsLayerParams = new WMSOptions();
wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);
wmsLayerParams.setBuffer(0);
wmsLayerParams.setSingleTile(false);
wmsLayerParams.setLayerOpacity(1.0);
Bounds layerBounds = ProjectionUtilities.transform(new
Bounds(100000,100000,350000,200000), "EPSG:24100", "EPSG:24200");
wmsLayerParams.setMaxExtent(layerBounds);
// set the layer projection to the display projection so that
// any necessary reprojection can be done on the server
wmsLayerParams.setProjection("EPSG:24200");
WMS wmsLayer = new WMS("WMSLAyer1", "http://localhost/geoserver/wms",
wmsParams, wmsLayerParams);
// add layer projection for later use
wmsLayer.getJSObject().setProperty("srs", "EPSG:24100");
// Add layer to open layers map
map.addLayer(wmsLayer);
wmsParams = new WMSParams();
wmsParams.setFormat("image/png");
wmsParams.setLayers("WMSLayer2");
wmsParams.setIsTransparent(true);
wmsParams.setStyles("");
wmsLayerParams = new WMSOptions();
wmsLayerParams.setTransitionEffect(TransitionEffect.RESIZE);
wmsLayerParams.setBuffer(0);
wmsLayerParams.setSingleTile(false);
wmsLayerParams.setLayerOpacity(1.0);
layerBounds = ProjectionUtilities.transform(new
Bounds(500000,500000,850000,700000), "EPSG:24200", "EPSG:24200");
wmsLayerParams.setMaxExtent(layerBounds);
// set the layer projection to the display projection so that
// any necessary reprojection can be done on the server
wmsLayerParams.setProjection("EPSG:24200");
wmsLayer = new WMS("WMSLAyer2", "http://localhost/geoserver/wms",
wmsParams, wmsLayerParams);
// add layer projection for later use
wmsLayer.getJSObject().setProperty("srs", "EPSG:24200");
// Add layer to open layers map
map.addLayer(wmsLayer);
GoogleOptions gOptions = new GoogleOptions();
gOptions.setSphericalMercator(true);
gOptions.setDisplayInLayerSwitcher(false);
gOptions.setDisplayOutsideMaxExtent(true);
// gOptions.setNumZoomLevels(22);
gOptions.setLayerOpacity(1.0);
layerBounds = ProjectionUtilities.transform(new Bounds(
Double.parseDouble(layer.getMinx()), Double.parseDouble(layer.getMiny()),
Double.parseDouble(layer.getMaxx()), Double.parseDouble(layer.getMaxy())),
"EPSG:900913", "EPSG:24200");
gOptions.setMaxExtent(layerBounds);
gOptions.setIsBaseLayer(false);
// GMapType gmapType = GMapType.G_SATELLITE_MAP;
// gOptions.setType(gmapType);
Google gLayer = new Google(layer.getTitle(), gOptions);
// Add layer to open layers map
map.addLayer(gLayer);
map.setCenter(layerBounds.getCenterLonLat());
// ========================================================================= //
I've tried setting the google maps layer to base layer but that changed nothing.
If I load only the google maps layer it still displays the world multiple
times side by side, and when I zoom to my location and then load
one of the other layers, I don't see it so I guess the projection stuff isn't
working. I have the following projection javascripts and definitions loaded:
<script src="openlayers/proj4js/proj4js-compressed.js"></script>
<script src="openlayers/proj4js/projCode/lcc.js"></script>
<script src="openlayers/proj4js/projCode/merc.js"></script>
<script src="openlayers/proj4js/projCode/tmerc.js"></script>
<script src="openlayers/proj4js/defs/EPSG.js"></script>
<script src="openlayers/OpenLayers.js"></script>
where EPSG.js contains:
Proj4js.defs["EPSG:24100"] = "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77
+k_0=1 +x_0=167638.49597 +y_0=121918.90616 +a=6378249.144808011
+b=6356514.966204134 +to_meter=0.3047972654 +no_defs";
Proj4js.defs["EPSG:24200"] = "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77
+k_0=1 +x_0=250000 +y_0=150000 +ellps=clrk66 +units=m +no_defs";
Proj4js.defs["EPSG:3448"] = "+proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77
+k_0=1 +x_0=750000 +y_0=650000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0
+units=m +no_defs";
Proj4js.defs["EPSG:32618"] = "+proj=utm +zone=18 +ellps=WGS84
+datum=WGS84 +units=m +no_defs";
Proj4js.defs["EPSG:900913"] = "+proj=merc +a=6378137 +b=6378137
+lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null
+no_defs";
Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
I've also tried setting my display projection to EPSG:900913 but the
result is the same.
Can anyone see what I'm doing wrong.
John
|