[mapserver-users] Mapserver layer over Google Maps

Alberto Najera anajera at bicimapas.com.mx
Mon May 7 20:06:32 EDT 2012


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
anajera at bicimapas.com.mx
 
   Búscanos como Bicimapas
 

-----Mensaje original-----
De: Dejan Gambin [mailto:dejan.gambin at coin.hr] 
Enviado el: lunes, 07 de mayo de 2012 01:20 a.m.
Para: Alberto Najera
CC: mapserver-users at lists.osgeo.org
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
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list