Tile load slowly
Dear All,
While displaying map in Adobe flex the tiles are loading very slowly. I used to dumbed the data's in PostgreSQL, and WMS in geoserver.
Is any body know what's the reason is?
Here is the coding
----------------------
/**
* MapProvider for a WMS server, in either EPSG:4326 or EPSG:900913
*/
package com.modestmaps.mapproviders
{
import com.modestmaps.core.Coordinate;
import com.modestmaps.geo.LinearProjection;
import com.modestmaps.geo.Location;
import com.modestmaps.geo.Transformation;
import flash.net.URLVariables;
public class WMSMapProvider extends AbstractMapProvider implements IMapProvider
{
public static const EPSG_4326:String = "EPSG:4326";
public static const EPSG_900913:String = "EPSG:900913";
public static const DEFAULT_PARAMS:Object = {
FORMAT: 'image/png',
VERSION: '1.1.1',
SERVICE: 'WMS',
REQUEST: 'GetMap',
SRS: 'EPSG:4326',
WIDTH: '512',
HEIGHT: '512',
BGCOLOR: '0xF2EFE9'
};
private var serverUrl:String;
private var wmsParams:Object;
private var wms:String;
public var layers:Array;
public function WMSMapProvider(serverURL:String, wmsParams:Object=null)
{
super();
layers = ['stateboundary','area_try','streams','waterbodies','road_network','rail_roads','majorcities'];
if (!wmsParams) wmsParams = DEFAULT_PARAMS;
this.serverUrl = serverURL;
this.wmsParams = wmsParams;
var data:URLVariables = new URLVariables();
for (var param:String in wmsParams) {
data[param] = wmsParams[param];
}
this.wms = "?" + data.toString();
if (wmsParams['SRS'] == EPSG_4326) {
var t:Transformation = new Transformation(166886.05360752725, 0, 524288, 0, -166886.05360752725, 524288);
__projection = new LinearProjection(20, t);
}
else if (wmsParams['SRS'] && wmsParams['SRS'] != EPSG_900913) {
throw new Error("[WMSMapProvider] Only Linear and (Google-style) Mercator projections are currently supported");
}
}
public function getTileUrls(coord:Coordinate):Array
{
var worldSize:int = Math.pow(2, coord.zoom);
if (coord.row < 0 || coord.row >= worldSize) {
return [];
}
var sourceCoord:Coordinate = sourceCoordinate(coord);
var bottomLeftCoord:Coordinate = sourceCoord.down();
var topRightCoord:Coordinate = sourceCoord.right();
var boundingBox:String;
var laywms:String = this.wms + "&layers=";
var first:Boolean = true;
for each(var lay:String in layers) {
if(!first) {
laywms = laywms + ",";
}
first = false;
laywms = laywms + lay;
}
if (wmsParams['SRS'] == EPSG_4326) {
// lat-lon is easy
var bottomLeftLocation:Location = coordinateLocation(bottomLeftCoord);
var topRightLocation:Location = coordinateLocation(topRightCoord);
boundingBox = '&BBOX=' + [ bottomLeftLocation.lon.toFixed(5),
bottomLeftLocation.lat.toFixed(5),
topRightLocation.lon.toFixed(5),
topRightLocation.lat.toFixed(5) ].join(',')
return [serverUrl + laywms + boundingBox];
}
var quadrantWidth:Number = 20037508.34;
var magicZoom:Number = Math.log(2*quadrantWidth) / Math.LN2;
bottomLeftCoord = bottomLeftCoord.zoomTo(magicZoom);
topRightCoord = topRightCoord.zoomTo(magicZoom);
// flip and offset so we have correct minx,miny,maxx,maxy
var minx:Number = bottomLeftCoord.column - quadrantWidth;
var miny:Number = quadrantWidth - bottomLeftCoord.row;
var maxx:Number = topRightCoord.column - quadrantWidth;
var maxy:Number = quadrantWidth - topRightCoord.row;
boundingBox = '&BBOX=' + [ minx.toFixed(5), miny.toFixed(5), maxx.toFixed(5), maxy.toFixed(5) ].join(',')
return [ serverUrl + laywms + boundingBox ];
}
public function toString() : String
{
return "WMS";
}
override public function get tileWidth():Number
{
return 512;
}
override public function get tileHeight():Number
{
return 512;
}
}
}
regards
K.JAYAKUMAR
While displaying map in Adobe flex the tiles are loading very slowly. I used to dumbed the data's in PostgreSQL, and WMS in geoserver.
Is any body know what's the reason is?
Here is the coding
----------------------
/**
* MapProvider for a WMS server, in either EPSG:4326 or EPSG:900913
*/
package com.modestmaps.mapproviders
{
import com.modestmaps.core.Coordinate;
import com.modestmaps.geo.LinearProjection;
import com.modestmaps.geo.Location;
import com.modestmaps.geo.Transformation;
import flash.net.URLVariables;
public class WMSMapProvider extends AbstractMapProvider implements IMapProvider
{
public static const EPSG_4326:String = "EPSG:4326";
public static const EPSG_900913:String = "EPSG:900913";
public static const DEFAULT_PARAMS:Object = {
FORMAT: 'image/png',
VERSION: '1.1.1',
SERVICE: 'WMS',
REQUEST: 'GetMap',
SRS: 'EPSG:4326',
WIDTH: '512',
HEIGHT: '512',
BGCOLOR: '0xF2EFE9'
};
private var serverUrl:String;
private var wmsParams:Object;
private var wms:String;
public var layers:Array;
public function WMSMapProvider(serverURL:String, wmsParams:Object=null)
{
super();
layers = ['stateboundary','area_try','streams','waterbodies','road_network','rail_roads','majorcities'];
if (!wmsParams) wmsParams = DEFAULT_PARAMS;
this.serverUrl = serverURL;
this.wmsParams = wmsParams;
var data:URLVariables = new URLVariables();
for (var param:String in wmsParams) {
data[param] = wmsParams[param];
}
this.wms = "?" + data.toString();
if (wmsParams['SRS'] == EPSG_4326) {
var t:Transformation = new Transformation(166886.05360752725, 0, 524288, 0, -166886.05360752725, 524288);
__projection = new LinearProjection(20, t);
}
else if (wmsParams['SRS'] && wmsParams['SRS'] != EPSG_900913) {
throw new Error("[WMSMapProvider] Only Linear and (Google-style) Mercator projections are currently supported");
}
}
public function getTileUrls(coord:Coordinate):Array
{
var worldSize:int = Math.pow(2, coord.zoom);
if (coord.row < 0 || coord.row >= worldSize) {
return [];
}
var sourceCoord:Coordinate = sourceCoordinate(coord);
var bottomLeftCoord:Coordinate = sourceCoord.down();
var topRightCoord:Coordinate = sourceCoord.right();
var boundingBox:String;
var laywms:String = this.wms + "&layers=";
var first:Boolean = true;
for each(var lay:String in layers) {
if(!first) {
laywms = laywms + ",";
}
first = false;
laywms = laywms + lay;
}
if (wmsParams['SRS'] == EPSG_4326) {
// lat-lon is easy
var bottomLeftLocation:Location = coordinateLocation(bottomLeftCoord);
var topRightLocation:Location = coordinateLocation(topRightCoord);
boundingBox = '&BBOX=' + [ bottomLeftLocation.lon.toFixed(5),
bottomLeftLocation.lat.toFixed(5),
topRightLocation.lon.toFixed(5),
topRightLocation.lat.toFixed(5) ].join(',')
return [serverUrl + laywms + boundingBox];
}
var quadrantWidth:Number = 20037508.34;
var magicZoom:Number = Math.log(2*quadrantWidth) / Math.LN2;
bottomLeftCoord = bottomLeftCoord.zoomTo(magicZoom);
topRightCoord = topRightCoord.zoomTo(magicZoom);
// flip and offset so we have correct minx,miny,maxx,maxy
var minx:Number = bottomLeftCoord.column - quadrantWidth;
var miny:Number = quadrantWidth - bottomLeftCoord.row;
var maxx:Number = topRightCoord.column - quadrantWidth;
var maxy:Number = quadrantWidth - topRightCoord.row;
boundingBox = '&BBOX=' + [ minx.toFixed(5), miny.toFixed(5), maxx.toFixed(5), maxy.toFixed(5) ].join(',')
return [ serverUrl + laywms + boundingBox ];
}
public function toString() : String
{
return "WMS";
}
override public function get tileWidth():Number
{
return 512;
}
override public function get tileHeight():Number
{
return 512;
}
}
}
regards
K.JAYAKUMAR
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?I don't think this has anything to do with Modest Maps. If you are rendering your own tiles using GeoServer and PostGIS then you should ask about optimisation in the forums for that software.
If you don't think it's an issue with rendering time on the server then you can use Apple's Safari web browser or the Firebug extension to Firefox to look at the load time of each image. If the images are loading quickly but not being shown in Modest Maps then please post back with more info.
In your provider, is there a reason you're not passing the layers argument in with the wmsParams as intended? Something like:
var layers:Array = [ 'stateboundary', 'area_try', 'streams', 'waterbodies', 'road_network', 'rail_roads', 'majorcities' ];
var wmsProvider:WMSMapProvider = new WMSMapProvider("http://example.com", {
LAYERS: layers.join(','),
FORMAT: 'image/png',
VERSION: '1.1.1',
SERVICE: 'WMS',
REQUEST: 'GetMap',
SRS: 'EPSG:900913',
WIDTH: '256',
HEIGHT: '256'
});
If the layers change you should call map.setMapProvider otherwise the old layers will continue to be cached.
Note the use of Array.join instead of a for-loop to insert the commas - hopefully at least that's useful!
Loading Profile...



EMPLOYEE