PHP code example of ministryofweb / php-osm-tiles

1. Go to this page and download the library: Download ministryofweb/php-osm-tiles library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ministryofweb / php-osm-tiles example snippets




use MinistryOfWeb\OsmTiles\Converter;
use MinistryOfWeb\OsmTiles\LatLng;

$converter = new Converter();
$point     = new LatLng(52.5, 13.4);
$zoom      = 13;

$tile = $converter->toTile($point, $zoom);

printf('/tiles/%d/%d/%d.png', $zoom, $tile->x, $tile->y);



use MinistryOfWeb\OsmTiles\Converter;
use MinistryOfWeb\OsmTiles\Tile;

$converter = new Converter();
$tile     = new Tile(4400, 2687, 13);

$point = $converter->toLatLng($tile);

printf('%.5f, %.5f', $point->lat, $point->lat);



use MinistryOfWeb\OsmTiles\LatLng;
use MinistryOfWeb\OsmTiles\Tile;
use MinistryOfWeb\OsmTiles\TileBounds;

$tile = Tile::fromLocation(new LatLng(52.5, 13.5));

echo 'South-eastern point for tile is located at: ' . TileBounds::getSouthEast($tile)->lat . ', ' . TileBounds::getSouthEast($tile)->lng . PHP_EOL;
shell
composer 
text
/tiles/13/4400/2687.png