places2be / osm-tiles
Downloads OSM tiles
1.3.0
2022-10-02 20:43 UTC
Requires
- php: ^7.2 || ^8.0
- places2be/position: ^1.3
- psr/log: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- monolog/monolog: ^2.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Places2Be OSM Tiles
Downloads OSM tiles.
Installation
This package is made for the use with Composer. Add it to your project by running $ composer require places2be/osm-tiles.
Usage
Set up the class like that:
<?php
use Places2Be\OSM\Tiles;
$folder = '/path/to/your/tiles';
$servers = [
'https://a.osm.rrze.fau.de/osmhd/{{zoom}}/{{tileX}}/{{tileY}}.png',
'https://b.osm.rrze.fau.de/osmhd/{{zoom}}/{{tileX}}/{{tileY}}.png',
'https://c.osm.rrze.fau.de/osmhd/{{zoom}}/{{tileX}}/{{tileY}}.png',
];
$tiles = new Tiles($folder, $servers);
Note that the server urls contains placeholders.
Download a tile by calling
<?php
$tiles->getTile(8611, 5640, 14);
If you have coordinates instead of the X and Y values, you can convert them by calling
<?php
use Places2Be\Position\Coordinates;
$coordinates = new Coordinates(48.806035, 9.213587);
$tilesNames = $tiles->getTileNames($coordinates, 14);
$tiles->getTile($tilesNames['x'], $tilesNames['y'], 14);
Alternatively you can use it like that
<?php
use Places2Be\Position\Coordinates;
$coordinates = new Coordinates(48.806035, 9.213587);
$tiles->getTileFromCoordinates($coordinates, 14);
Help
If you have any questions, feel free to contact us under hello@bitandblack.com.
Further information about Bit&Black can be found under www.bitandblack.com.