[mapserver-users] Mapserver layer over Google Maps

Dejan Gambin dejan.gambin at coin.hr
Sun May 6 23:19:50 PDT 2012


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
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the MapServer-users mailing list