places2be/osm-tiles

1.2.0 2020-03-16 07:38 UTC

This package is auto-updated.

Last update: 2020-09-17 14:59:32 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 questions feel free to contact us under places2be-osm-tiles@bitandblack.com.