[OpenLayers-Users] Zooming with multiple kamap layers

Mike Leahy mgleahy at alumni.uwaterloo.ca
Sat Jul 26 04:58:31 EDT 2008


Ok - here's a better demonstration of this problem.  Copy this into an 
html file...open it in a browser, then zoom in.  You'll see what I'm 
talking about.  This is using the World Map and Places layers from one 
of the ka-map demos hosted by omniverdi.org.  Is it something I'm doing 
wrong with the OL code, or maybe a bug in OL's kamap layer object?

Regards,
Mike

=======================================================================

<html>
<head>
  <title>OpenLayers Example</title>
   <script
   src="http://www.openlayers.org/api/OpenLayers.js"></script>
   </head>
   <body>
    <div style="width:100%; height:100%" id="map"></div>
    <script defer="defer" type="text/javascript">
     var options = {
      maxExtent: new OpenLayers.Bounds(-180,-90,180,90),
      scales: 
[100000000,50000000,25000000,10000000,5000000,2500000,1000000],
      numZoomLevels: 8,
      tileSize: new OpenLayers.Size(200,200),
       projection:  "EPSG:4326",
           units:  "dd"
         };
         var  map  =  new  OpenLayers.Map('map',options);

         var  ly1  =  new  OpenLayers.Layer.KaMap("World  Map",
           "http://clima.ominiverdi.org/ka-map/htdocs/tile.php",
           {i:"JPEG",map:"cvs",g:"World  Map",version:"6"}
         );
         var  ly2  =  new  OpenLayers.Layer.KaMap("Places",
           "http://clima.ominiverdi.org/ka-map/htdocs/tile.php",
           {i:"PNG",map:"cvs",g:"Places",version:"6"}
         );

         map.addLayers([ly1,ly2]);
         map.zoomToExtent(new  OpenLayers.Bounds(-180,-90,180,90));
         ly2.setVisibility(true);
       </script>
</body>
</html>




Mike  Leahy  wrote:
>  Hello  list,
>  
>  I've  been  working  on  an  application  that  uses  Ka-Map,  but  I  think  I  
>  might  consider  adopting  OpenLayers  for  the  client-side  part.    I  have  
>  been  able  to  setup  a  map  that  loads  two  layers  (see  sample  HTML  below).  
>      When  the  map  initially  starts,  I  call  roads.setVisibility(true);,  and  
>  I  see  the  roads  layer  overlaid  on  top  of  the  aerial  photography  layer.  
>  It  looks  fine  at  that  point...panning  works  fine.    Once  I  zoom  in  or  
>  out,  however,  the  base  layer  (the  photography)  does  what  is  expected,  
>  but  the  roads  layer  just  defaults  to  its  original  extent,  and  remains  at  
>  the  initial  zoom  level.    Is  there  something  I  need  to  do  to  tie  the  
>  roads  layer  to  the  zoom  event?
>  
>  If  this  is  a  known  issue,  or  if  I'm  just  missing  something,  maybe  
>  someone  can  point  me  in  the  right  direction.    I'm  using  OpenLayers  2.6  
>  (should  I  try  SVN?).    The  tile.php  script  is  something  that  I  have  
>  integrated  into  my  application  on  the  server  -  it's  generally  based  on  
>  the  one  from  kamap  (checked  out  of  svn  about  a  month  ago),  but  I  don't  
>  think  it's  the  source  of  this  issue  (i.e.,  if  I  make  the  roads  layer  the  
>  base  layer  on  its  own,  it  works  fine).
>  
>  Thanks  in  advance  for  any  help,
>  Mike
>  
>  ======================================================================
>  
>  <html>
>  <head>
>      <title>OpenLayers    Example</title>
>          <script
>          src="https://localhost/application/js/lib/OpenLayers.js"></script>
>          </head>
>          <body>
>              <div    style="width:100%;    height:100%"    id="map"></div>
>              <script    defer="defer"    type="text/javascript">
>                  var    options    =    {
>                      maxExtent:    new  
>  OpenLayers.Bounds(1327479,4883397,1415461,5034462),
>                      scales:    [200000,150000,100000,75000,50000,25000,10000,5000],
>                      numZoomLevels:    8,
>                      tileSize:    new    OpenLayers.Size(400,300),
>                      projection:    "EPSG:4326",
>                      units:    "m"
>                  };
>                  var    map    =    new    OpenLayers.Map('map',options);
>                  var    aerials    =    new    OpenLayers.Layer.KaMap("mymap",
>                      "https://localhost/application/tile.php",
>                      {layers:"0",i:"AGG_JPEG",map:"mymap",g:"Aerial  
>  Photography",sid:"somesessionid"}
>                  );
>                  var    roads    =    new    OpenLayers.Layer.KaMap("mymap",
>                      "https://localhost/application/tile.php",
>  
>  {layers:"160",i:"alpha",map:"mymap",g:"Roads",sid:"somesessionid"},
>                      {numZoomLevels:8,scales:  
>  [200000,150000,100000,75000,50000,25000,10000,5000]}
>                  );
>                  map.addLayers([aerials,roads]);
>                  map.zoomToExtent(new  
>  OpenLayers.Bounds(1373558,4988812,1404038,5011460));
>                  roads.setVisibility(true);
>              </script>
>  </body>
>  </html>
>  



More information about the Users mailing list