|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Latitude and Longitude of the center of individual tilesHello all,
Is there any possibility to get the latitude and longitude of the center of individual tiles in setTile() and to pass this values as parameters of the http call to tile.php? I've written a custom tile.php to use openstreetmaps and I would need this values (lat lon) as parameters passed to to this script. Thanks in advance, Ionut Muntean _______________________________________________ ka-Map-users mailing list ka-Map-users@... http://lists.maptools.org/mailman/listinfo/ka-map-users |
|
|
kaMap - setTile function - uses openstreetmap servers.kaMap - setTile function - uses openstreetmap servers.
File that replaces init.php. Paste the code below in a file on your server and load it at run time instead of init.php. /*init*/ aszScales = new Array('110936068.18103503','55468034.09051751','27734017.045258757', '13867008.522629378','6933504.261313272','3466752.130658053', '1733376.0653290264','866688.0326645132','433344.0163322566', '216672.008164711','108336.00408377283','54168.002041886415', '27084.001020943208','13542.000510471604','6771.000253818478', '3385.5001283265624','1692.7500655806048'); var mResolutions = new Array('156543.0339', '78271.51695', '39135.758475', '19567.8792375', '9783.93961875', '4891.969809375', '2445.984904687', '1222.992452344', '611.496226172', '305.748113086', '152.874056543', '76.437028271', '38.218514136', '19.109257068', '9.554628534', '4.777314267', '2.388657133', '1.194328567', '0.597164284'); var map = new _map({name:'Terra',title:'World',currentScale:2,units:3,resolution:72,version:'3',scales:aszScales, resolutions:mResolutions}); map.setDefaultExtents(-20037508.34, -200037508.34, 200037508.34, 200037508.34); map.setBackgroundColor('rgb(244,244,234)'); map.addLayer(new _layer( { name:'Terra',visible:true,opacity:100,imageformat:'png',queryable:false,tileSource:'auto',redrawInterval:-1,refreshInterval:-1,scales: new Array('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1')})); this.addMap( map ); this.tileWidth=256; this.tileHeight=256; this.server = 'http://xxx.xxx.xxx/'; this.tileURL = 'http://a.tile.osm.dmtech.ro/tiles/'; this.cacheURL = 'http://localcache.xxx.xxx/tiles/'; this.selectMap('Terra'); Replace setTile with the function below. _layer.prototype.setTile = function(img) { var tforce = _settings.alwaysForceDraw; if (arguments.length == 2) tforce = true; var mercExtents = new Array('-20037508.34', '20037508.34'); var zIdx = (this._map.currentScale + 2); // osm zooms are from 0 to 18. azScales contains only calculated scales from 2 to 18 ... var res = this._map.resolutions[zIdx]; var km = this._map.kaMap; var left = km.cellSize * (safeParseInt(img.style.left) + km.xOrigin); var top = -1 * km.cellSize * (safeParseInt(img.style.top) + km.yOrigin); var right = left + km.cellSize * km.tileWidth; var bottom = top - km.cellSize * km.tileHeight; if (left < mercExtents[0] || left > mercExtents[2] || top < mercExtents[0] || top > mercExtents[1]) return false; var limit = Math.pow(2, zIdx); var x = Math.round((left - mercExtents[0]) / (res * km.tileWidth)); var y = Math.round((mercExtents[1] - top) / (res * km.tileHeight)); if (y < 0 || y >= limit) return false; x = ((x % limit) + limit) % limit; if (tforce) { var src = this._map.kaMap.tileURL + zIdx + '/' + x + '/' + y + '.png'; } else { var src = this._map.kaMap.cacheURL + zIdx + '/' + x + '/' + y + '.png'; } if (img.src != src) { img.style.visibility = 'hidden'; img.src = src; } }; Have fun! Ionut Muntean _______________________________________________ ka-Map-users mailing list ka-Map-users@... http://lists.maptools.org/mailman/listinfo/ka-map-users |
|
|
Re: kaMap - setTile function - uses openstreetmap servers.Ionut, I don't have the time to test this now but sounds very cool
thanks a lot! Ionut Muntean wrote: > kaMap - setTile function - uses openstreetmap servers. > > File that replaces init.php. Paste the code below in a file on your > server and load it at run time instead of init.php. > > /*init*/ > aszScales = new > Array('110936068.18103503','55468034.09051751','27734017.045258757', > '13867008.522629378','6933504.261313272','3466752.130658053', > '1733376.0653290264','866688.0326645132','433344.0163322566', > '216672.008164711','108336.00408377283','54168.002041886415', > '27084.001020943208','13542.000510471604','6771.000253818478', > '3385.5001283265624','1692.7500655806048'); > var mResolutions = new Array('156543.0339', '78271.51695', > '39135.758475', '19567.8792375', '9783.93961875', '4891.969809375', > '2445.984904687', > '1222.992452344', '611.496226172', > '305.748113086', '152.874056543', '76.437028271', '38.218514136', > '19.109257068', > '9.554628534', '4.777314267', '2.388657133', > '1.194328567', '0.597164284'); > var map = new > _map({name:'Terra',title:'World',currentScale:2,units:3,resolution:72,version:'3',scales:aszScales, > resolutions:mResolutions}); > map.setDefaultExtents(-20037508.34, -200037508.34, 200037508.34, > 200037508.34); > map.setBackgroundColor('rgb(244,244,234)'); > map.addLayer(new _layer( { > name:'Terra',visible:true,opacity:100,imageformat:'png',queryable:false,tileSource:'auto',redrawInterval:-1,refreshInterval:-1,scales: > new > Array('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1')})); > this.addMap( map ); > this.tileWidth=256; > this.tileHeight=256; > this.server = 'http://xxx.xxx.xxx/'; > this.tileURL = 'http://a.tile.osm.dmtech.ro/tiles/'; > this.cacheURL = 'http://localcache.xxx.xxx/tiles/'; > this.selectMap('Terra'); > > > Replace setTile with the function below. > > _layer.prototype.setTile = function(img) { > var tforce = _settings.alwaysForceDraw; > if (arguments.length == 2) > tforce = true; > var mercExtents = new Array('-20037508.34', '20037508.34'); > var zIdx = (this._map.currentScale + 2); // osm zooms are from 0 to > 18. azScales contains only calculated scales from 2 to 18 ... > var res = this._map.resolutions[zIdx]; > var km = this._map.kaMap; > var left = km.cellSize * (safeParseInt(img.style.left) + km.xOrigin); > var top = -1 * km.cellSize * (safeParseInt(img.style.top) + km.yOrigin); > var right = left + km.cellSize * km.tileWidth; > var bottom = top - km.cellSize * km.tileHeight; > if (left < mercExtents[0] || left > mercExtents[2] || top < > mercExtents[0] || top > mercExtents[1]) return false; > var limit = Math.pow(2, zIdx); > var x = Math.round((left - mercExtents[0]) / (res * km.tileWidth)); > var y = Math.round((mercExtents[1] - top) / (res * km.tileHeight)); > if (y < 0 || y >= limit) return false; > x = ((x % limit) + limit) % limit; > if (tforce) { > var src = this._map.kaMap.tileURL + zIdx + '/' + x + '/' + y + '.png'; > } else { > var src = this._map.kaMap.cacheURL + zIdx + '/' + x + '/' + y + > '.png'; > } > if (img.src != src) { > img.style.visibility = 'hidden'; > img.src = src; > } > }; > > > > Have fun! > Ionut Muntean > > > _______________________________________________ > ka-Map-users mailing list > ka-Map-users@... > http://lists.maptools.org/mailman/listinfo/ka-map-users > > ka-Map-users mailing list ka-Map-users@... http://lists.maptools.org/mailman/listinfo/ka-map-users |
| Free embeddable forum powered by Nabble | Forum Help |