[OpenLayers-Users] show two layers with different projections

M_Airola mairola at gmail.com
Thu Mar 11 16:21:57 EST 2010


Ummm. I wonder what happens if you try the following:

Try putting your data over Google. (By the way, this will only work on a
local machine unless you have an API key which is free, but I didn't include
it in my example:

 <script
src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=INSERT_YOUR_KEY_HERE'
type='text/javascript'></script>
    <script src="http://www.openlayers.org/api/OpenLayers.js"
type="text/javascript"></script>

var options = {
    controls: [],
    projection: new OpenLayers.Projection("EPSG:900913"),
    displayProjection: new OpenLayers.Projection("EPSG:4326"),
    units: "m",
    maxResolution: 156543.0339,
    maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508,
20037508.34)
        };
map = new OpenLayers.Map('map', options);

var gmap = new OpenLayers.Layer.Google("Google Streets",
                    { sphericalMercator: true, numZoomLevels: 20,
                    isBaseLayer: true} );


Then add your layers, remove the projection options from the WMS layer add
like this:
 wmslayer = new OpenLayers.Layer.WMS ("IowaWomen",
            "http://localhost:8080/geoserver/wms",
            {'layers':'IAWomen:ia_locations',
'format':'image/png','transparent':'true'},
            {'opacity':1.0,'isBaseLayer':false,'visibility':false}

Make sure the projections are set correctly on the geoserver side. This has
worked for me.
The google is in the EPSG:900913 stuff and my data in in EPSG:26915.

The key might be checking the projection is set correctly on the geoserver
side.  Good luck.
-Matt
-- 
View this message in context: http://n2.nabble.com/show-two-layers-with-different-projections-tp4717734p4718802.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list