[OpenLayers-Users] Tilecache and 3rd party layers

Jennifer Strahan jennifer at greeninfo.org
Fri Feb 9 16:32:52 EST 2007


Hello List,

Is it possible to set up an OpenLayers map that allows users to 
toggle between a Tilecache basemap and a third party basemap such as 
the Google Hybrid layer?  I've set up a test and when I switch 
between the two layers the map scale changes dramatically.  Any 
suggestions or work-arounds would be appreciated.  The code I'm 
playing with is below.

Thanks,
Jennifer

<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <style type="text/css">
         #map {
             width: 700px;
             height: 700px;
             border: 1px solid black;
             background-color: white;
         }
     </style>
         <!-- this gmaps key generated for http://openlayers.org/dev/ -->
             <script 
src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAw874S7GDJrTKF-hByeq-RBTw3BVAxQz7_zJnwc-4a2w6zwgAIBSWyVuG8kPDqlCqZwwfIc2TyWWSSA'></script>
             <!-- Localhost key -->
             <!-- <script 
src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAw874S7GDJrTKF-hByeq-RBTw3BVAxQz7_zJnwc-4a2w6zwgAIBSWyVuG8kPDqlCqZwwfIc2TyWWSSA'></script>-->
     <script 
src="http://dev.openlayers.org/sandbox/tschaub/gutter/lib/OpenLayers.js"></script>


     <script type="text/javascript">
         <!--
         var map, layer;

         function init(){

             var options = { maxExtent: new 
OpenLayers.Bounds(-125.77,13.05,-66.31,60.81),
                                         'maxResolution': .1161328125,
                                     controls: [new 
OpenLayers.Control.MouseDefaults()]
                 };

             map = new OpenLayers.Map( $('map'), options );

             var natearth = new OpenLayers.Layer.WMS( "Natural Earth",
                                                           "http://82.165.243.230/cgi-bin/tilecache-1.3/tilecache.cgi?",
                                                           {layers: 
'natearth', format:'image/jpeg'});
             map.addLayer(natearth);

             var g_hybrid = new OpenLayers.Layer.Google( "Google 
Hybrid" , {type: G_HYBRID_MAP});
             map.addLayer(g_hybrid);


             map.setCenter(new OpenLayers.LonLat(-119.38, 37.45), 4);
             map.addControl( new OpenLayers.Control.LayerSwitcher() );
             map.addControl( new OpenLayers.Control.PanZoomBar() );
           map.addControl(new OpenLayers.Control.Scale());

         }



     // -->

     </script>
   </head>
   <body onload="init()">


     <div id="map"></div>

   </body>
</html>





Jennifer Strahan
GreenInfo Network - 1996-2006: A Decade of Mapping the Public Interest
116 New Montgomery  Street   Suite 738  San Francisco CA  94105
PH: (415)979-0343 x306    Fax:  415-979-0371     Web:  www.greeninfo.org






More information about the Users mailing list