places2be/osm-tiles

Downloads OSM tiles

1.1.0 2019-01-03 21:02 UTC

This package is auto-updated.

Last update: 2020-02-21 21:16:42 UTC


README

PHP 7.1 Codacy Badge Latest Stable Version Total Downloads License composer.lock

Places2Be OSM Tiles

Downloads OSM tiles.

Developer Guide

Installation

This package is available for the use with Composer. Use composer to install by running $ composer require places2be/osm-tiles and $ composer update.

How to use

Set up the class like that:

<?php

$folder = dirname(__FILE__).'/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 Places2Be\OSM\Tiles($folder, $servers); 

$zoom = 14;

Note that the server urls contains placeholders.

Download a tile by calling

<?php

$tiles->getTile(8611, 5640, $zoom);

If you have coordinates instead of the X and Y values, you can convert them by calling

<?php

$coordinates = new Places2Be\Position\Coordinates(48.806035, 9.213587);

$tilesNames = $tiles->getTileNames($coordinates, $zoom);

$tiles->getTile($tilesNames['x'], $tilesNames['y'], $zoom);

Alternatively you can use it like that

<?php

$coordinates = new Places2Be\Position\Coordinates(48.806035, 9.213587);

$tiles->getTileFromCoordinates($coordinates, $zoom);

Help

If you have questions feel free to contact us under places2be-osm-tiles@bitandblack.com.