R: AW: [OpenLayers-Users] Get tiles from bounds

francescoboccacci at libero.it francescoboccacci at libero.it
Tue Apr 17 17:06:26 EDT 2012


Thanks Arnd.. thanks for your answer .. it works..

Francesco

>----Messaggio originale----
>Da: arnd.wippermann at web.de
>Data: 17/04/2012 22.42
>A: <francescoboccacci at libero.it>
>Cc: <users at openlayers.org>
>Ogg: AW: [OpenLayers-Users] Get tiles from bounds
>
>Something like this should return the tiles url (OSM) for a given location:
>
>function getURLforLocation(ll, z)
>{
>    var lyrOSM    = map.layers[1];
>    var maxExtent = lyrOSM.maxExtent;
>    var tileSize  = lyrOSM.tileSize;
>    var resArr    = lyrOSM.resolutions;
>
>    var x = Math.floor((ll.lon - maxExtent.left) / (resArr[z] *
>tileSize.w));
>    var y = Math.floor((maxExtent.top - ll.lat) / (resArr[z] * tileSize.h));
>
>    var url = "http://tile.openstreetmap.org/${z}/${x}/${y}.png";
>    var path = OpenLayers.String.format(url, {x: x, y: y, z: z});
>    return path;
>}
>
>var Msg = "";
>var NL = "\n";
>
>//Freiheitsstatue
>var ll = new OpenLayers.LonLat(-74.0445225093636,40.68924187031257);
>var xy = ll.transform(new OpenLayers.Projection("EPSG:4326"), new
>OpenLayers.Projection("EPSG:900913"));
>
>var tilesUrl = "";
>for(var i=0;i<19;i++)
>    tilesUrl += getURLforLocation(xy, i) + "\n";
>
>console.log(tilesUrl);
>
>Arnd
>
> 
>
>-----Ursprüngliche Nachricht-----
>Von: openlayers-users-bounces at lists.osgeo.org
>[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von
>francescoboccacci at libero.it
>Gesendet: Montag, 16. April 2012 22:22
>An: openlayers-users at lists.osgeo.org
>Betreff: [OpenLayers-Users] Get tiles from bounds
>
>Hi all,
>i have a question about how to get all tiles url from getURL(bounds) from
>different zoom level.
>I explain my purpose: I use an OSM layer and i like to know what is the tile
>from different zoom level that cover the center of the map.
>
>mytiles = new OpenLayers.Layer.OSM ()
>
>mytiles.getURL(bounds) i get http://localhost/tiles/10/1/1000.png for
>example. 
>(zoom level 10)
>
>How is possible to get the tiles URL for example of zoom 9 or zoom 11?
>
>Thanks
>
>Francesco
>
>
>
>_______________________________________________
>Users mailing list
>Users at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>




More information about the Users mailing list