Mapserver layer over Google Maps

classic Classic list List threaded Threaded
3 messages Options
ANC
Reply | Threaded
Open this post in threaded view
|

Mapserver layer over Google Maps

ANC
Hello list,

Using OpenLayers, I am trying to draw a Mapserver WMS layer on top of Google
Maps. I am aware of the Spherical Mercator projection and I am trying to use
the alias projection method described at the end of this link

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

The mapserver layer is in Lat/Lon WGS84 (EPSG:4326)
I have made some progress so far and I can see the label of the object at
full zoom, but as I zoom in it does not show anymore and the feature does
not show either.

Any help in finding the issue would be greatly appreciated.

This is the relevant map file code:

MAP
........
WEB
    TEMPLATE "/home/bicimapas/www/bcmpms.html"
    IMAGEPATH "/home/bicimapas/www/images/"
    IMAGEURL "/images/"    
    METADATA
    "wms_title" "BiciMapasMS"
    "wms_onlineresource"
"http://my_host/cgi-bin/mapserv?map=/home/bicimapas/mapdata/BiciMapasMS_Metr
o.map&"
    "wms_srs" "EPSG:4326 EPSG:3857"
    "wms_enable_request" "*"
    END
END

PROJECTION
    "init=epsg:4326"
END

LAYER
    NAME "fibraoptica"
    DATA "fibraoptica"
    STATUS on
    TYPE line
    LABELCACHE on
    LABELITEM "RASGO"
    CLASSITEM "RASGO"
    METADATA
    "wms_title" "fibraoptica"
    "wms_srs" "EPSG:4326"
    "wms_include_items" "all"
    END
CLASS
        NAME "fibraoptica"
        EXPRESSION "fibra"
        #MAXSCALEDENOM 15000
        STYLE
            WIDTH 4
            COLOR 0 0 0
        END
        STYLE
            WIDTH 2
            COLOR 255 0 0
        END      
        LABEL
            TYPE truetype
            FONT "Arial"
            #MAXSCALEDENOM 15000
            ANTIALIAS true
            SIZE 7
            OUTLINECOLOR 255 255 255
            COLOR 0 0 0
            POSITION cc
            ANGLE follow
        END # label trutype
        END # class fibraoptica
END # layer fibraoptica    

END # mapfile

And the OpenLayers code is:


<html lang='en'>
<head>
    <meta charset='utf-8' />
    <script type='text/javascript' src='OpenLayers.js'></script>
        <script
src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type='text/javascript'>

    var map;
   
    function init() {
        // Setup map object
        map = new OpenLayers.Map('map_element', {});
       
                // Add Google Maps Layer
                var google_map_layer = new OpenLayers.Layer.Google(
                        'Google Map Layer',
                        {"sphericalMercator": true}
                );

     // override default epsg code
                        aliasproj = new OpenLayers.Projection("EPSG:3857");
                        google_map_layer.projection = aliasproj;

                // Add the Google Maps layer
                map.addLayer(google_map_layer);

                //add the mapserver layer
       
    var layer3 = new OpenLayers.Layer.WMS(
                "Fibra Optica",
                "http://my_host/cgi-bin/mapserv?",
                {map: '/home/bicimapas/mapdata/BiciMapasMS_Metro.map',
                layers:'fibraoptica', transparent: true},
{isBaseLayer:false});
       
    // Add the layer
                map.addLayer(layer3);    
       
        // Add a layer switcher control
        map.addControl(new OpenLayers.Control.LayerSwitcher({}));
       
        //Zoom the map to the max extent
                if(!map.getCenter()){
                map.zoomToMaxExtent();
                }
    }
    </script>
</head>


Thanks in advance

Alberto Najera

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Mapserver layer over Google Maps

dgambin1
Alberto,

I found this VERY useful: http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze

I think you should put EPSG:3857 on the first place in wms_srs

regards, dejan
On 7. svi. 2012., at 03:33, Alberto Najera wrote:

> Hello list,
>
> Using OpenLayers, I am trying to draw a Mapserver WMS layer on top of Google
> Maps. I am aware of the Spherical Mercator projection and I am trying to use
> the alias projection method described at the end of this link
>
> http://docs.openlayers.org/library/spherical_mercator
>
> The mapserver layer is in Lat/Lon WGS84 (EPSG:4326)
> I have made some progress so far and I can see the label of the object at
> full zoom, but as I zoom in it does not show anymore and the feature does
> not show either.
>
> Any help in finding the issue would be greatly appreciated.
>
> This is the relevant map file code:
>
> MAP
> ........
> WEB
>    TEMPLATE "/home/bicimapas/www/bcmpms.html"
>    IMAGEPATH "/home/bicimapas/www/images/"
>    IMAGEURL "/images/"    
>    METADATA
>    "wms_title" "BiciMapasMS"
>    "wms_onlineresource"
> "http://my_host/cgi-bin/mapserv?map=/home/bicimapas/mapdata/BiciMapasMS_Metr
> o.map&"
>    "wms_srs" "EPSG:4326 EPSG:3857"
>    "wms_enable_request" "*"
>    END
> END
>
> PROJECTION
>     "init=epsg:4326"
> END
>
> LAYER
>    NAME "fibraoptica"
>    DATA "fibraoptica"
>    STATUS on
>    TYPE line
>    LABELCACHE on
>    LABELITEM "RASGO"
>    CLASSITEM "RASGO"
>    METADATA
>    "wms_title" "fibraoptica"
>    "wms_srs" "EPSG:4326"
>    "wms_include_items" "all"
>    END
> CLASS
>        NAME "fibraoptica"
>        EXPRESSION "fibra"
>        #MAXSCALEDENOM 15000
>        STYLE
>            WIDTH 4
>            COLOR 0 0 0
>        END
>        STYLE
>            WIDTH 2
>            COLOR 255 0 0
>        END      
> LABEL
>    TYPE truetype
>    FONT "Arial"
>    #MAXSCALEDENOM 15000
>    ANTIALIAS true
>    SIZE 7
>    OUTLINECOLOR 255 255 255
>            COLOR 0 0 0
>            POSITION cc
>     ANGLE follow
>        END # label trutype
> END # class fibraoptica
> END # layer fibraoptica    
>
> END # mapfile
>
> And the OpenLayers code is:
>
>
> <html lang='en'>
> <head>
>    <meta charset='utf-8' />
>    <script type='text/javascript' src='OpenLayers.js'></script>
> <script
> src="http://maps.google.com/maps/api/js?sensor=false"></script>
>    <script type='text/javascript'>
>
>    var map;
>
>    function init() {
>        // Setup map object
>        map = new OpenLayers.Map('map_element', {});
>
> // Add Google Maps Layer
> var google_map_layer = new OpenLayers.Layer.Google(
> 'Google Map Layer',
> {"sphericalMercator": true}
> );
>
>     // override default epsg code
> aliasproj = new OpenLayers.Projection("EPSG:3857");
> google_map_layer.projection = aliasproj;
>
> // Add the Google Maps layer
> map.addLayer(google_map_layer);
>
> //add the mapserver layer
>
>     var layer3 = new OpenLayers.Layer.WMS(
> "Fibra Optica",
> "http://my_host/cgi-bin/mapserv?",
> {map: '/home/bicimapas/mapdata/BiciMapasMS_Metro.map',
> layers:'fibraoptica', transparent: true},
> {isBaseLayer:false});
>
>    // Add the layer
> map.addLayer(layer3);    
>
>        // Add a layer switcher control
>        map.addControl(new OpenLayers.Control.LayerSwitcher({}));
>
>        //Zoom the map to the max extent
> if(!map.getCenter()){
> map.zoomToMaxExtent();
> }
>    }
>    </script>
> </head>
>
>
> Thanks in advance
>
> Alberto Najera
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
ANC
Reply | Threaded
Open this post in threaded view
|

RE: Mapserver layer over Google Maps

ANC
Dejan,

What I was missing was adding the maxExtent parameters in the map object
using the Spherical Mercator values. As soon as I added them, it worked.

The article you referenced is very good.

Thanks

Alberto Najera
www.bicimapas.com.mx
www.bicimapas.com.mx/Empresa.htm
Avenida Lomas Verdes No. 58, Local 17
Colonia Santa Cruz Acatlán
Naucalpan, Estado de México
México CP 53150
Tel: (55) 53 60 30 65
[hidden email]
 
   Búscanos como Bicimapas
 

-----Mensaje original-----
De: Dejan Gambin [mailto:[hidden email]]
Enviado el: lunes, 07 de mayo de 2012 01:20 a.m.
Para: Alberto Najera
CC: [hidden email]
Asunto: Re: [mapserver-users] Mapserver layer over Google Maps

Alberto,

I found this VERY useful:
http://geographika.co.uk/mapserver-openlayers-and-the-wfs-maze

I think you should put EPSG:3857 on the first place in wms_srs

regards, dejan
On 7. svi. 2012., at 03:33, Alberto Najera wrote:

> Hello list,
>
> Using OpenLayers, I am trying to draw a Mapserver WMS layer on top of
> Google Maps. I am aware of the Spherical Mercator projection and I am
> trying to use the alias projection method described at the end of this
> link
>
> http://docs.openlayers.org/library/spherical_mercator
>
> The mapserver layer is in Lat/Lon WGS84 (EPSG:4326) I have made some
> progress so far and I can see the label of the object at full zoom,
> but as I zoom in it does not show anymore and the feature does not
> show either.
>
> Any help in finding the issue would be greatly appreciated.
>
> This is the relevant map file code:
>
> MAP
> ........
> WEB
>    TEMPLATE "/home/bicimapas/www/bcmpms.html"
>    IMAGEPATH "/home/bicimapas/www/images/"
>    IMAGEURL "/images/"    
>    METADATA
>    "wms_title" "BiciMapasMS"
>    "wms_onlineresource"
> "http://my_host/cgi-bin/mapserv?map=/home/bicimapas/mapdata/BiciMapasM
> S_Metr
> o.map&"
>    "wms_srs" "EPSG:4326 EPSG:3857"
>    "wms_enable_request" "*"
>    END
> END
>
> PROJECTION
>     "init=epsg:4326"
> END
>
> LAYER
>    NAME "fibraoptica"
>    DATA "fibraoptica"
>    STATUS on
>    TYPE line
>    LABELCACHE on
>    LABELITEM "RASGO"
>    CLASSITEM "RASGO"
>    METADATA
>    "wms_title" "fibraoptica"
>    "wms_srs" "EPSG:4326"
>    "wms_include_items" "all"
>    END
> CLASS
>        NAME "fibraoptica"
>        EXPRESSION "fibra"
>        #MAXSCALEDENOM 15000
>        STYLE
>            WIDTH 4
>            COLOR 0 0 0
>        END
>        STYLE
>            WIDTH 2
>            COLOR 255 0 0
>        END      
> LABEL
>    TYPE truetype
>    FONT "Arial"
>    #MAXSCALEDENOM 15000
>    ANTIALIAS true
>    SIZE 7
>    OUTLINECOLOR 255 255 255
>            COLOR 0 0 0
>            POSITION cc
>     ANGLE follow
>        END # label trutype
> END # class fibraoptica
> END # layer fibraoptica    
>
> END # mapfile
>
> And the OpenLayers code is:
>
>
> <html lang='en'>
> <head>
>    <meta charset='utf-8' />
>    <script type='text/javascript' src='OpenLayers.js'></script>
> <script
> src="http://maps.google.com/maps/api/js?sensor=false"></script>
>    <script type='text/javascript'>
>
>    var map;
>
>    function init() {
>        // Setup map object
>        map = new OpenLayers.Map('map_element', {});
>
> // Add Google Maps Layer
> var google_map_layer = new OpenLayers.Layer.Google(
> 'Google Map Layer',
> {"sphericalMercator": true}
> );
>
>     // override default epsg code
> aliasproj = new OpenLayers.Projection("EPSG:3857");
> google_map_layer.projection = aliasproj;
>
> // Add the Google Maps layer
> map.addLayer(google_map_layer);
>
> //add the mapserver layer
>
>     var layer3 = new OpenLayers.Layer.WMS(
> "Fibra Optica",
> "http://my_host/cgi-bin/mapserv?",
> {map: '/home/bicimapas/mapdata/BiciMapasMS_Metro.map',
> layers:'fibraoptica', transparent: true},
{isBaseLayer:false});

>
>    // Add the layer
> map.addLayer(layer3);    
>
>        // Add a layer switcher control
>        map.addControl(new OpenLayers.Control.LayerSwitcher({}));
>
>        //Zoom the map to the max extent
> if(!map.getCenter()){
> map.zoomToMaxExtent();
> }
>    }
>    </script>
> </head>
>
>
> Thanks in advance
>
> Alberto Najera
>
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


_______________________________________________
mapserver-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-users