places2be/osm-tiles

1.3.0 2022-10-02 20:43 UTC

This package is auto-updated.

Last update: 2024-03-20 15:38:38 UTC


README

PHP from Packagist Codacy Badge Latest Stable Version Total Downloads License

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.