[Tilecache] Overlays - WMS on top of Google using TileCache

mmmmmm mguraliuc1978 at yahoo.com
Thu Jan 15 09:02:59 EST 2009


Thank you Chris for your answer.
After clearing my mind, reading your post and starting from scratch I
managed to get things working.

Here is the complete settings used:

1. Geoserver 1.7 data defined as below:

Data min X:  27.49844  Data min Y:  46.99977  
Data max X:  27.99847  Data max Y:  47.33311 
SRS: 4326
SRS Handeling: Reproject from native to declared SRS 

2. Tilecache config:
[basic]
type=WMS
layers=topp:line
url=http://10.10.10.241:8081/geoserver/wms?transparent=true
extension=png

size=256,256
levels=18

# this 3 lines below match the exact settings of the map object defined in
the javascript
# also they match Google's SRS and BBOX
srs=EPSG:900913
maxResolution=156543.0313
bbox=-20037508,-20037508,20037508,20037508

extent_type=loose

3. The html page including the script.
NOTE the settings used to initialize the OpenLayers.Map object. It seems
that the overlay that you will be adding over the Google Layer (which is
base layer) needs to have the same extent and zoom levels (hence resolution
array) as the base layer.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <style type="text/css">
     	#map {
            width: 100%;
            height: 100%;            
        	}
		body {
	  		padding:0px; 
	  		margin:0px;
			} 		
    </style>
    
        
    <script src="./javascript/OpenLayers.js"
type="text/javascript"></script>

    <script src="http://maps.google.com/maps?file=api&amp;v=2'; ....>
INCLUDE THE RIGHT API KEY HERE
           
    <script type="text/javascript">       

        var map;
        // avoid pink tiles
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 4;
        OpenLayers.Util.onImageLoadErrorColor = "transparent";
        
        function init()
        {           	
        	
var options = 
{
projection: new OpenLayers.Projection("EPSG:900913"),                                
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: 'm',
numZoomLevels: 18,
maxResolution: 156543.0313,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,20037508, 20037508),                              
controls: 
[					
new OpenLayers.Control.PanZoomBar(),                                                
new OpenLayers.Control.ScaleLine({
	topOutUnits: "mi",
	topInUnits: "ft",
	bottomOutUnits: "km",
	bottomInUnits: "m"										}),						
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.Navigation({ 'zoomWheelEnabled': true})					
]
};        	            
            
            
            map = new OpenLayers.Map('map', options);    
            
            
            // --- Google Maps Layer //G_SATELLITE_MAP		//G_HYBRID_MAP	
//G_PHYSICAL_MAP                       
            var gsat = new OpenLayers.Layer.Google("GMaps2", {type:
G_HYBRID_MAP,'sphericalMercator': true});                      
            map.addLayers([gsat]);
            
 
            
            // --- Tilecache layer            
			var layer2 = new OpenLayers.Layer.WMS( "VMap0",
                    "http://scada2/tilecache-2.04/tilecache.py",
				{
					layers: 'basic',
					reproject: false,					
		                   	tiled: 'true'
				}, 
				{
					isBaseLayer: false,
					opacity: 1.0
				} 
				);
			map.addLayer(layer2);			        
								

    		
    		
    		var bCenter = true;
			if(bCenter)
			{
				var center = new OpenLayers.LonLat(27.58731, 47.15125);	// PoduRos: 47
09 04.5, 27 35 14.4 = 47.15125, 27.58731       		    		
    			var projector = new OpenLayers.Projection("EPSG:4326");
    			if(map.getProjectionObject() == "EPSG:900913")
    			{
    				center = center.transform(projector, map.getProjectionObject());    			
    			}
    			map.setCenter(center, 13);   	
			}
			
    		
        }    
                      


			
    </script>
  </head>
  <body onload="init()">
    <div id="map" style="background-color: #88cccc"></div>
   </body>
</html>




-----
Best regards,
Mitica
-- 
View this message in context: http://n2.nabble.com/Overlays---WMS-on-top-of-Google-using-TileCache-tp1837822p2162538.html
Sent from the TileCache mailing list archive at Nabble.com.




More information about the Tilecache mailing list