Aller au contenu

omnimap/openstreetmap Référence de l’API

Étage
Fournisseur · Omnimap
Version
1.x
Suite de conformité
branchée, CI verte
Vérifié en réel
Vérifié en partie
Licence
MIT
composer require omnimap/openstreetmap:1.x-dev

Lue dans les fichiers PHP du paquet au commit 4f3fa313c6b2 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.

Omnimap\OpenStreetMap

  • OpenStreetMapFactory class

    OpenStreetMap, from its options:

    14 options · 1 method · 3 constants

  • OpenStreetMapProvider class

    OpenStreetMap: the live map drawn by Leaflet (assets/leaflet.js) over a tile server, a view as an image made on the server from the same tiles (Static\TileStitcher: fetched with the application's User-Agent, kept as long as the server's Cache-Control allows), and geocoding through geocoder-php's Nominatim provider (one call a second at most, answers kept).

    15 methods · 1 constant

Omnimap\OpenStreetMap

OpenStreetMapFactory class

final class OpenStreetMapFactory extends ProviderFactory OpenStreetMapFactory.php:33

OpenStreetMap, from its options:

tiles the tile URL, {z}/{x}/{y} in it (and {s} for a server's subdomains). The default is the OpenStreetMap Foundation's server, whose policy allows normal viewing and forbids heavy use: in production, a tile provider of your own choice or your own server attribution as HTML, shown on the map (the data's licence requires it) max_zoom 19 tile_size 256 user_agent the application's name and a contact, sent with every request the server makes (tiles, Nominatim): required by both policies - a library's default User-Agent is blocked referer sent with them too, when set nominatim the geocoder's URL (https://nominatim.openstreetmap.org); empty: no geocoding nominatim_interval seconds between two geocoder calls of a process (1: "an absolute maximum of 1 request per second") leaflet_script, leaflet_style, leaflet_script_integrity, leaflet_style_integrity where the browser gets Leaflet (unpkg, 1.9.4, with its hashes): serve your own copy to keep the visitor's browser off a CDN background the colour above and below the world on an image made of tiles

Options

OptionDefault
tilesself::OSM_TILES
attributionself::OSM_ATTRIBUTION
max_zoom19
tile_size256
user_agent''
referer''
nominatimself::NOMINATIM
nominatim_interval1.0
geocoder_ttl2592000
leaflet_script'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js'
leaflet_script_integrity'sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo='
leaflet_style'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css'
leaflet_style_integrity'sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY='
background'#aad3df'
const OSM_TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
const OSM_ATTRIBUTION = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
const NOMINATIM = 'https://nominatim.openstreetmap.org'

OpenStreetMapFactory::__construct()

public function __construct(readonly ?HttpClientInterface $http = null, readonly ?ClientInterface $psr18 = null, readonly ?CacheInterface $cache = null)

OpenStreetMapProvider class

final class OpenStreetMapProvider implements MapRendererInterface, StaticMapInterface, GeocoderInterface, TileSourceInterface OpenStreetMapProvider.php:32

OpenStreetMap: the live map drawn by Leaflet (assets/leaflet.js) over a tile server, a view as an image made on the server from the same tiles (Static\TileStitcher: fetched with the application's User-Agent, kept as long as the server's Cache-Control allows), and geocoding through geocoder-php's Nominatim provider (one call a second at most, answers kept).

Nothing of a view's options is OpenStreetMap's own but MapView::options('openstreetmap')['map'] - Leaflet's map options, as JSON.

const SUBDOMAINS = ['a', 'b', 'c']

What {s} of a tile URL stands for: Leaflet's default subdomains.

OpenStreetMapProvider::__construct()

public function __construct(readonly string $tiles = OpenStreetMapFactory::OSM_TILES, readonly string $attribution = OpenStreetMapFactory::OSM_ATTRIBUTION, readonly int $maxZoom = 19, readonly int $tileSize = 256, readonly ?string $userAgent = null, readonly ?string $referer = null, readonly array $leaflet = [], readonly string $background = '#aad3df', readonly ?HttpClientInterface $http = null, readonly ?CacheInterface $cache = null, readonly ?GeocoderPhp $geocoder = null)

OpenStreetMapProvider::getName()

public function getName(): string

OpenStreetMapProvider::getTitle()

public function getTitle(): string

OpenStreetMapProvider::capabilities()

public function capabilities(): Capabilities

OpenStreetMapProvider::describe()

public function describe(MapView $view): array

OpenStreetMapProvider::fingerprint()

public function fingerprint(MapView $view): string

OpenStreetMapProvider::attribution()

public function attribution(): string

OpenStreetMapProvider::image()

public function image(MapView $view, Size $size, int $scale = 1): Image

OpenStreetMapProvider::template()

public function template(): string

OpenStreetMapProvider::url()

public function url(int $zoom, int $x, int $y): string

OpenStreetMapProvider::tileSize()

public function tileSize(): int

OpenStreetMapProvider::maxZoom()

public function maxZoom(): int

OpenStreetMapProvider::headers()

public function headers(): array

The User-Agent the policy asks for (none: refused here rather than blocked there), and the Referer when set.

OpenStreetMapProvider::geocode()

public function geocode(string $address, ?string $locale = null, int $limit = 5): array

OpenStreetMapProvider::reverse()

public function reverse(LatLng $position, ?string $locale = null, int $limit = 5): array