diff --git a/web/index.html b/web/index.html index acafd42f..22e6d836 100644 --- a/web/index.html +++ b/web/index.html @@ -31,7 +31,7 @@ - + diff --git a/web/js/custommarker.js b/web/js/custommarker.js index e40c4640..7126f834 100644 --- a/web/js/custommarker.js +++ b/web/js/custommarker.js @@ -20,10 +20,7 @@ L.CustomMarker = L.Class.extend({ if (!this._element && this.options.elementCreator) { this._element = this.options.elementCreator(); - - // TODO: Pass this fix to Leaflet-dev(s), it may be a bug in Leaflet. - this._element.style.position = 'absolute'; - + this._element.className += ' leaflet-marker-icon'; this._initInteraction(); } diff --git a/web/js/dynmaputils.js b/web/js/dynmaputils.js index f97f0964..e09b9419 100644 --- a/web/js/dynmaputils.js +++ b/web/js/dynmaputils.js @@ -1,4 +1,7 @@ var DynmapProjection = L.Class.extend({ + initialize: function(options) { + L.Util.setOptions(this, options); + }, fromLocationToLatLng: function(location) { throw "fromLocationToLatLng not implemented"; } diff --git a/web/js/flatmap.js b/web/js/flatmap.js index 3235235b..c32c9682 100644 --- a/web/js/flatmap.js +++ b/web/js/flatmap.js @@ -5,13 +5,14 @@ var FlatProjection = DynmapProjection.extend({ }); var FlatMapType = DynmapTileLayer.extend({ - projection: new FlatProjection({}), options: { minZoom: 0, maxZoom: 4 }, initialize: function(options) { + options.maxZoom = options.mapzoomin + options.world.extrazoomout; L.Util.setOptions(this, options); + this.projection = new FlatProjection({extrazoom: this.options.world.extrazoomout}); }, getTileName: function(tilePoint, zoom) { var tileName; @@ -19,13 +20,32 @@ var FlatMapType = DynmapTileLayer.extend({ if(this.options.nightandday && this.dynmap.serverday) { dnprefix = '_day'; } - tileName = this.options.prefix + dnprefix + '_128_' + tilePoint.x + '_' + tilePoint.y + '.png'; + var extrazoom = this.options.world.extrazoomout; + if(zoom < extrazoom) { + var scale = 1 << (extrazoom-zoom); + var zprefix = "zzzzzzzzzzzz".substring(0, extrazoom-zoom); + if(this.options.bigmap) { + tileName = this.options.prefix + dnprefix + '_128/' + ((scale*tilePoint.x) >> 5) + '_' + ((scale*tilePoint.y) >> 5) + '/' + zprefix + "_" + (scale*tilePoint.x) + '_' + (scale*tilePoint.y) + '.png'; + } else { + tileName = zprefix + this.options.prefix + dnprefix + '_128_' + (scale*tilePoint.x) + '_' + (scale*tilePoint.y) + '.png'; + } + } + else { + if(this.options.bigmap) { + tileName = this.options.prefix + dnprefix + '_128/' + (tilePoint.x >> 5) + '_' + (tilePoint.y >> 5) + '/' + tilePoint.x + '_' + tilePoint.y + '.png'; + } else { + tileName = this.options.prefix + dnprefix + '_128_' + tilePoint.x + '_' + tilePoint.y + '.png'; + } + } return tileName; }, calculateTileSize: function(zoom) { - return Math.pow(2, 7+zoom); + var extrazoom = this.options.world.extrazoomout; + return (zoom < extrazoom) + ? 128 + : Math.pow(2, 7+zoom-extrazoom); } -}) +}); /* function FlatMapType(configuration) { diff --git a/web/js/hdmap.js b/web/js/hdmap.js index 57cab961..adf2d08b 100644 --- a/web/js/hdmap.js +++ b/web/js/hdmap.js @@ -1,22 +1,54 @@ -function HDProjection() {} -HDProjection.prototype = { - extrazoom: 0, - worldtomap: null, - fromLatLngToPoint: function(latLng) { - return new google.maps.Point(latLng.lng()*config.tileWidth, latLng.lat()*config.tileHeight); - }, - fromPointToLatLng: function(point) { - return new google.maps.LatLng( point.y/config.tileHeight, point.x/config.tileWidth); - }, - fromWorldToLatLng: function(x, y, z) { - var wtp = this.worldtomap; - var xx = wtp[0]*x + wtp[1]*y + wtp[2]*z; - var yy = wtp[3]*x + wtp[4]*y + wtp[5]*z; - - return new google.maps.LatLng( (1 - (yy / config.tileHeight)) / (1 << this.extrazoom), xx / config.tileWidth / (1 << this.extrazoom)); - } -}; +var HDProjection = DynmapProjection.extend({ + fromLocationToLatLng: function(location) { + var wtp = this.options.worldtomap; + console.log(wtp); + var xx = wtp[0]*location.x + wtp[1]*location.y + wtp[2]*location.z; + var yy = wtp[3]*location.x + wtp[4]*location.y + wtp[5]*location.z; + var lat = xx / (8 << this.options.extrazoom); + var lng = (128-yy) / (8 << this.options.extrazoom); + return new L.LatLng(lat, lng, true); + } +}); +var HDMapType = DynmapTileLayer.extend({ + projection: undefined, + options: { + minZoom: 0, + maxZoom: 3 + }, + initialize: function(options) { + options.maxZoom = options.mapzoomin + options.world.extrazoomout; + L.Util.setOptions(this, options); + this.projection = new HDProjection({worldtomap: options.worldtomap}) + }, + getTileName: function(tilePoint, zoom) { + var tileName; + + var dnprefix = ''; + if(this.options.nightandday && this.options.dynmap.serverday) + dnprefix = '_day'; + + var extrazoom = this.options.mapzoomout; + if(zoom < extrazoom) { + var scale = 1 << (extrazoom-zoom); + var zprefix = "zzzzzzzzzzzzzzzzzzzzzz".substring(0, extrazoom-zoom); + tileName = this.options.prefix + dnprefix + '/' + ((scale*tilePoint.x) >> 5) + '_' + ((-scale*tilePoint.y) >> 5) + '/' + zprefix + "_" + (scale*tilePoint.x) + '_' + (-scale*tilePoint.y) + '.png'; + } else { + tileName = this.options.prefix + dnprefix + '/' + (tilePoint.x >> 5) + '_' + ((-tilePoint.y) >> 5) + '/' + tilePoint.x + '_' + (-tilePoint.y) + '.png'; + } + return tileName; + }, + calculateTileSize: function(zoom) { + var extrazoom = this.options.mapzoomout; + console.log(zoom <= extrazoom, zoom, extrazoom); + return (zoom <= extrazoom) + ? 128 + : Math.pow(2, 7+zoom-extrazoom); + //128; + } +}); + +/* function HDMapType(configuration) { $.extend(this, configuration); } HDMapType.prototype = $.extend(new DynMapType(), { @@ -86,5 +118,5 @@ HDMapType.prototype = $.extend(new DynMapType(), { this.tileSize = new google.maps.Size(size, size); } }); - -maptypes.HDMapType = function(configuration) { return new HDMapType(configuration); }; \ No newline at end of file +*/ +maptypes.HDMapType = function(options) { return new HDMapType(options); }; diff --git a/web/js/kzedmaps.js b/web/js/kzedmaps.js index 96ed4f94..f2b711b1 100644 --- a/web/js/kzedmaps.js +++ b/web/js/kzedmaps.js @@ -1,130 +1,62 @@ -function KzedProjection() {} -KzedProjection.prototype = { - extrazoom: 0, - fromLatLngToPoint: function(latLng) { - var x = latLng.lng() * config.tileWidth; - var y = latLng.lat() * config.tileHeight; - - return new google.maps.Point(x, y); - }, - fromPointToLatLng: function(point) { - var lng = point.x / config.tileWidth; - var lat = point.y / config.tileHeight; - return new google.maps.LatLng(lat, lng); - }, - fromWorldToLatLng: function(x, y, z) - { - var dx = +x; - var dy = +y - 127; - var dz = +z; - var px = dx + dz; - var py = dx - dz - dy; - var scale = 2 << this.extrazoom; - - var lng = -px / config.tileWidth / scale + (1.0 / scale); - var lat = py / config.tileHeight / scale; - - return new google.maps.LatLng(lat, lng); - } -}; - -function KzedMapType(configuration) { $.extend(this, configuration); } -KzedMapType.prototype = $.extend(new DynMapType(), { - constructor: KzedMapType, - projection: new KzedProjection(), - tileSize: new google.maps.Size(128, 128), - minZoom: 0, - maxZoom: 3, - prefix: null, - getTile: function(coord, zoom, doc) { - var tileDebugText = null; - var tileSize = 128; - var tileName; - var imgSize; - - var debugred; - var debugblue; - +var KzedProjection = DynmapProjection.extend({ + fromLocationToLatLng: function(location) { + var dx = location.x; + var dy = location.y - 127; + var dz = location.z; + var px = dx + dz; + var py = dx - dz - dy; + var scale = 2 << this.options.extrazoom; + + var lat = px / scale - 64; + var lng = py / scale; + return new L.LatLng(-lat, lng, true); + } +}); + +var KzedMapType = DynmapTileLayer.extend({ + options: { + minZoom: 0, + maxZoom: 4 + }, + initialize: function(options) { + options.maxZoom = options.mapzoomin + options.world.extrazoomout; + L.Util.setOptions(this, options); + this.projection = new KzedProjection({extrazoom: this.options.world.extrazoomout}); + }, + getTileName: function(tilePoint, zoom) { + var tileSize = 128; + var tileName = ''; var dnprefix = ''; - if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].nightandday && this.dynmap.serverday) - dnprefix = '_day'; - var extrazoom = this.dynmap.world.extrazoomout; - if (zoom <= extrazoom) { - var zpre = 'zzzzzzzzzzzzzzzz'.substring(0, extrazoom-zoom); - // Most zoomed out tiles. - tileSize = 128; - imgSize = tileSize; + + if(this.options.nightandday && this.options.dynmap.serverday) { + dnprefix = '_day'; + } + var extrazoom = this.options.world.extrazoomout; + if (zoom <= extrazoom) { + var zpre = 'zzzzzzzzzzzzzzzz'.substring(0, extrazoom-zoom); + // Most zoomed out tiles. var tilescale = 2 << (extrazoom-zoom); - if (this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap) { + if (this.options.bigmap) { if(zoom < extrazoom) zpre = zpre + '_'; - tileName = 'z' + this.prefix + dnprefix + '/' + ((-coord.x * tileSize*tilescale)>>12) + - '_' + ((coord.y * tileSize*tilescale) >> 12) + '/' + zpre + - (-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png'; + tileName = 'z' + this.options.prefix + dnprefix + '/' + ((-tilePoint.x * tileSize*tilescale)>>12) + '_' + ((tilePoint.y * tileSize*tilescale) >> 12) + '/' + zpre + (-tilePoint.x * tileSize*tilescale) + '_' + (tilePoint.y * tileSize*tilescale) + '.png'; + } else { + tileName = zpre + 'z' + this.options.prefix + dnprefix + '_' + (-tilePoint.x * tileSize*tilescale) + '_' + (tilePoint.y * tileSize*tilescale) + '.png'; } - else { - tileName = zpre + 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png'; - } - } else { - // Other zoom levels. - tileSize = 128; - - imgSize = Math.pow(2, 6+zoom-extrazoom); - if(this.dynmap.map.mapTypes[this.dynmap.map.mapTypeId].bigmap) { - tileName = this.prefix + dnprefix + '/' + ((-coord.x*tileSize) >> 12) + '_' + - ((coord.y*tileSize)>>12) + '/' + - (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png'; + } else { + if(this.options.bigmap) { + tileName = this.options.prefix + dnprefix + '/' + ((-tilePoint.x*tileSize) >> 12) + '_' + ((tilePoint.y*tileSize)>>12) + '/' + (-tilePoint.x*tileSize) + '_' + (tilePoint.y*tileSize) + '.png'; + } else { + tileName = this.options.prefix + dnprefix + '_' + (-tilePoint.x*tileSize) + '_' + (tilePoint.y*tileSize) + '.png'; } - else { - tileName = this.prefix + dnprefix + '_' + (-coord.x*tileSize) + '_' + (coord.y*tileSize) + '.png'; - } - } - var img; - var tile = $('
') - .addClass('tile') - .css({ - width: tileSize + 'px', - height: tileSize + 'px' - }); - if (tileDebugText) { - $('') - .text(tileDebugText) - .css({ - position: 'absolute', - color: 'red' - }) - .appendTo(tile); - } - if (tileName) { - img = $('