Skip to main content

JXMapKit - Custom Tile Server: Same tiles being displayed

No replies
suntzu2007
Offline
Joined: 2010-05-25

Hi all,

This is a follow up of yesterday's problem (JXMapKit Latitude / Longitude - Custom Tile Server --> resolved). The problem now is that XMap displays the same tiles in each grid. Probably I'm missing something small here. My code is as follows:

final int max = 17;
TileFactoryInfo info = new TileFactoryInfo(
0, //min level
17, //max allowed level
max, // max level
256, //tile size
true, true, // x/y orientation is normal
null, // base url
null, null, null // url args for x, y and z
) {

@Override
public String getTileUrl(int x, int y, int zoom) {
System.out.println("Z: " + zoom);
zoom = max - zoom;
double zoom2 = zoomMap.get(zoom);
System.out.println(zoom + " " + zoom2);
double lat = (Math.round(tile2lat(y, zoom)) * 360000);
double lon = (Math.round(tile2lon(x, zoom)) * 360000);

String url = "http://some url?" + lat + " " + lon + "zoom etc";
return url;
}

private double tile2lon(int x, int z) {
return x / Math.pow(2.0, z) * 360.0 - 180;
}

private double tile2lat(int y, int z) {
double n = Math.PI - (2.0 * Math.PI * y) / Math.pow(2.0, z);
return Math.toDegrees(Math.atan(Math.sinh(n)));
}
};

Note that my tile server is using a slightly different zoom level, hence I am mapping 0 - 17 to my own zoom levels.

Any help would be greatly appreciated...
Thanks for your time.