Add zoom limits for SlippyMap layers
This commit is contained in:
parent
5ec53b4c36
commit
a622f6f37e
3 changed files with 22 additions and 5 deletions
|
@ -1282,12 +1282,15 @@ var TileLayer = {
|
|||
map: map,
|
||||
group: group.createChild("group", me.type),
|
||||
maps_base: "",
|
||||
controller: controller,
|
||||
num_tiles: [5,5],
|
||||
makeURL: nil,
|
||||
makePath: nil,
|
||||
center_tile_offset : [],
|
||||
tile_size: 256,
|
||||
zoom: 9,
|
||||
max_zoom: 16,
|
||||
min_zoom: 4,
|
||||
tile_type: "map",
|
||||
last_tile_type: "map",
|
||||
last_tile : [-1,-1],
|
||||
|
@ -1311,7 +1314,6 @@ var TileLayer = {
|
|||
append(m.parents, m.group);
|
||||
m.setVisible(visible);
|
||||
OverlayLayer._new(m, style, controller, options);
|
||||
#m.group.setCenter(0,0);
|
||||
|
||||
for(var x = 0; x < m.num_tiles[0]; x += 1)
|
||||
{
|
||||
|
@ -1326,6 +1328,8 @@ var TileLayer = {
|
|||
},
|
||||
updateLayer: func()
|
||||
{
|
||||
if (me.controller != nil) me.controller.updateLayer();
|
||||
|
||||
# get current position
|
||||
var lat = me.map.getLat();
|
||||
var lon = me.map.getLon();
|
||||
|
@ -1341,7 +1345,11 @@ var TileLayer = {
|
|||
# 156543.03 meters/pixel * cos(latitude) / (2 ^ zoomlevel)
|
||||
# Determine the closest zoom level and scaling ratio. Each increase in zoom level doubles resolution.
|
||||
var ideal_zoom = math.ln(156543.03 * math.cos(lat * math.pi/180.0) / screen_resolution) / math.ln(2);
|
||||
|
||||
me.zoom = math.ceil(ideal_zoom);
|
||||
if (me.zoom < me.min_zoom) me.zoom = me.min_zoom;
|
||||
if (me.zoom > me.max_zoom) me.zoom = me.max_zoom;
|
||||
|
||||
var ratio = 1 / math.pow(2,me.zoom - ideal_zoom);
|
||||
|
||||
for(var x = 0; x < me.num_tiles[0]; x += 1)
|
||||
|
@ -1354,9 +1362,6 @@ var TileLayer = {
|
|||
}
|
||||
}
|
||||
|
||||
#var heading = me.map.getHdg();
|
||||
#me.group.setRotation(heading);
|
||||
|
||||
var ymax = math.pow(2, me.zoom);
|
||||
|
||||
# Slippy map location of center point
|
||||
|
|
|
@ -21,6 +21,9 @@ var new = func(layer) {
|
|||
layer.makeURL = string.compileTemplate('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png');
|
||||
layer.makePath = string.compileTemplate(layer.maps_base ~ '/osm-intl/{z}/{x}/{y}.png');
|
||||
|
||||
layer.max_zoom = 18;
|
||||
layer.min_zoom = 1;
|
||||
|
||||
m.addVisibilityListener();
|
||||
m.addRangeListener();
|
||||
m.addScreenRangeListener();
|
||||
|
|
|
@ -19,9 +19,18 @@ var new = func(layer) {
|
|||
};
|
||||
|
||||
# http://1.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/6/30/43.png
|
||||
layer.makeURL = string.compileTemplate('http://1.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{tms_y}.png');
|
||||
|
||||
if (rand() < 0.5) {
|
||||
layer.makeURL = string.compileTemplate('http://1.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{tms_y}.png');
|
||||
} else {
|
||||
layer.makeURL = string.compileTemplate('http://2.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{tms_y}.png');
|
||||
}
|
||||
|
||||
layer.makePath = string.compileTemplate(layer.maps_base ~ '/openaip_basemap/{z}/{x}/{tms_y}.png');
|
||||
|
||||
layer.max_zoom = 14;
|
||||
layer.min_zoom = 4;
|
||||
|
||||
m.addVisibilityListener();
|
||||
m.addRangeListener();
|
||||
m.addScreenRangeListener();
|
||||
|
|
Loading…
Reference in a new issue