[OpenLayers-Users] Google basemap with overlay layer

Marcello Brunaldi marcello.brunaldi at student.unife.it
Tue Feb 10 17:14:40 EST 2009


I changed my code in this way
Now I will display the marker at the right distance but the coordinates do
not correspond to reality but the wms layer unesco not be seen.
I need to change the encoding in Geoserver EPSG from 4326 to 900,913 for the
wms layer unesco?

function init()
{
        options={
                projection: new OpenLayers.Projection("EPSG: 900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),
                numZoomLevels:18,
                units: "m",
                maxResolution: 156543.0339,
                maxExtent: new OpenLayers.Bounds(-20037508.34,
-20037508.34,20037508.34, 20037508.34)
            };
        //creo la mappa di base con i parametri
        map = new OpenLayers.Map('map', options);

        var myBaseLayer = new OpenLayers.Layer.Google("Google",
              {'sphericalMercator': true,
               'maxExtent': new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
              });

        //creo i livelli con la zona unesco

        unesco = new OpenLayers.Layer.WMS(
                "TOPP unesco",
                "http://localhost:8080/geoserver/wms?",
                {
                   layers: 'topp:unesco',
                   styles: '',
                   srs: 'EPSG:900913',
                   format: 'image/png',
                   tiled: 'true',
                   tilesOrigin : "0,0",
                   transparent: true
                },

                {
                    'opacity': 0.5, 'isBaseLayer': false, 'wrapDateLine':
true
                }

            );


    file[0] = "georss/blu.xml";
    file[1] = "georss/rosso.xml";
    file[2] = "georss/verde.xml";
    file[3] = "georss/giallo.xml";
    file[4] = "georss/marrone.xml";
    file[5] = "georss/arancio.xml";
    file[6] = "georss/celeste.xml";
    file[7] = "georss/viola.xml";
    file[8] = "georss/bianco.xml";
    file[9] = "georss/nero.xml";

    new1= [];
    new1[0] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/blu.xml',
{'icon':color[0]} );
    new1[1] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/rosso.xml',
{'icon':color[1]} );
    new1[2] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/verde.xml',
{'icon':color[2]} );
    new1[3] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/giallo.xml',
{'icon':color[3]} );
    new1[4] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/marrone.xml',
{'icon':color[4]} );
    new1[5] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/arancio.xml',
{'icon':color[5]} );
    new1[6] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/celeste.xml',
{'icon':color[6]} );
    new1[7] = new OpenLayers.Layer.GeoRSS( 'GeoRSS', 'georss/viola.xml',
{'icon':color[7]} );

    map.addLayers([myBaseLayer,unesco]);
    //map.addLayers([unesco,aste]);
    //map.addLayers([unesco,aste,siepi,attrezzature,aree,alberi,edifici]);

    for (n=0; n < 8; n++)
    {
        map.addLayer(new1[n]);
    }

    map.addControl(new OpenLayers.Control.LayerSwitcher());
    loadsetmap();
    map.addControl(new OpenLayers.Control.Permalink());
    map.addControl(new OpenLayers.Control.MousePosition());


>On Mon, Feb 09, 2009 at 03:15:17PM +0100, Marcello Brunaldi wrote:
> Hello everyone
> I have several layers wms loaded directly from Geoserver, I can not map
> overlapping the basic google! It only shows google maps and layers do not
> see, the markers but instead appear not correspond to real coordinates.

> 1. Your Google layer doesn't have the spherical mercator option set.
> 2. Your map and layer projection are EPSG:4326, which is not correct.

> I recommend reading:

> http://docs.openlayers.org/library/spherical_mercator

> And understanding it better first.

> -- Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090210/29276646/attachment.html


More information about the Users mailing list