Commits

Oliver Tonnhofer committed d0fed7b

zoom tms demo client to map extent

Comments (0)

Files changed (2)

mapproxy/config/loader.py

                 md['name_path'] = (self.conf['name'], grid.srs.srs_code.replace(':', '').upper())
                 md['name_internal'] = md['name_path'][0] + '_' + md['name_path'][1]
                 md['format'] = self.context.caches[cache_name].image_opts().format
+                md['extent'] = extent
             
                 tile_layers.append(TileLayer(self.conf['name'], self.conf['title'],
                                              md, cache_source))

mapproxy/service/templates/demo/tms_demo.html

 wrapper = textwrap.TextWrapper(replace_whitespace=False, width=90,
                                break_long_words=False)
 
+def approx_bbox(layer, srs):
+    from mapproxy.srs import SRS
+    extent = layer.md['extent'].bbox_for(SRS(srs))
+    return ', '.join(map(lambda x: '%.2f' % x, extent))
+
 menu_title= "TMS %s %s"%(layer.name, srs)
 }}
 {{def jscript}}
     });
     
     map.addLayer(layer)
-    map.zoomToMaxExtent(); 
+    map.zoomToExtent(new OpenLayers.Bounds({{approx_bbox(layer, srs)}}));
 }
 </script>     
 {{enddef}}