[OpenLayers-Users] OpenLayers.Layer.TMS requesting too many tiles?

Brian Walawender Brian.Walawender at noaa.gov
Tue Feb 17 10:57:56 EST 2009


Hello,

I'm trying to have OpenLayers interact with TileCache similar to the way the
Google Maps and GTileLayerOverlay interacts with tilecache.    My Google
example will load in about 3 seconds (the tiles were already created) and
requests 55 tiles from the server.  My Openlayers application takes several
minutes to load and is requesting about 3 times as many tiles.  It also
spawns numerous Python processes on the servers and max out the CPU.  

Here is the snip from the Openlayers Code:

	var options = {
                                projection: new
OpenLayers.Projection("EPSG:900913"),
                                displayProjection: new
OpenLayers.Projection("EPSG:4326"),
                                units: "m",
                                controls: [],
                                maxExtent: new
OpenLayers.Bounds(-20037508.3427892,-20037508.3427892,20037508.3427892,20037
508.3427892),
                                numZoomLevels:8,
                                maxResolution:156543.0339,
                        };

       // Street Map
                        gstr = new OpenLayers.Layer.Google("Street Map", {
                                'sphericalMercator': true,
                                'minZoomLevel': 7,
                                'maxExtent': new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34)
                        });

	map.addLayer(gstr);

       function get_my_url (bounds) {
                                //bounds = map.getExtent();
                                var res = this.map.getResolution();
                                var x = Math.round ((bounds.left -
this.maxExtent.left) / (res * this.tileSize.w));
                                var y = Math.round ((this.maxExtent.top -
bounds.top) / (res * this.tileSize.h));
                                var z = this.map.getZoom();
                                z = z+7;

                               var path = z + "/" + x + "/" + y + "." +
this.type;
                               var url = this.url;
                               if (url instanceof Array) {
                                     url = this.selectUrl(path, url);
                               }
                               type = '?type=google';
                               return url + path + type;

                        }

                        var j = 0;
                        for (var i=3; i>-1; i--) {
                                layer = radar_id + '_n0r_' + j;
                                var tile_url = 'http:// 123.45.67.105
/tilecache/tilecache.cgi/1.0.0/' + layer + '/';
                                overlay[i] =  new OpenLayers.Layer.TMS(
"Radar", tile_url, {
                                        'isBaseLayer' : 'false',
                                        'type':'png',
                                        'numZoomLevels': 8,
                                        'getURL':get_my_url
                                });
                                map.addLayer(overlay[i]);
                                overlay[i].setOpacity(radarOpacity);
                                j++;
                        }

Why is Openlayers performing so poorly?

bw




More information about the Users mailing list