PHP code example of tearoom1 / kirby-leaflet-map

1. Go to this page and download the library: Download tearoom1/kirby-leaflet-map 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/ */

    

tearoom1 / kirby-leaflet-map example snippets


 snippet('leaflet-map/css') 

'tearoom1.leaflet-map.icons' => [
    'ferry' => [
        'label' => ['en' => 'Ferry', 'de' => 'Fähre'],
        'svg'   => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">…</svg>',
    ],
    'car' => false,
],

'tearoom1.leaflet-map.layers' => [
    'osm',      // OpenStreetMap
    'osm-de',   // OpenStreetMap Deutschland
    'topo',     // OpenTopoMap
    'cyclosm',  // CyclOSM
    'humanitarian',
    'default',  // the tiles.* options
    'satellite' => [
        'label'       => 'Satellite',
        'url'         => 'https://tiles.example.com/{z}/{x}/{y}.jpg',
        'attribution' => '…',
        'maxZoom'     => 18,
    ],
],

'tearoom1.leaflet-map.layers' => [
    'osm',
    // Germany only
    'basemap-de' => [
        'label'       => 'basemap.de',
        'url'         => 'https://sgx.geodatenzentrum.de/wmts_basemapde/tile/1.0.0/de_basemapde_web_raster_farbe/default/GLOBAL_WEBMERCATOR/{z}/{y}/{x}.png',
        'attribution' => '&copy; <a href="https://basemap.de">basemap.de</a> / BKG | Datenquellen: &copy; GeoBasis-DE',
        'maxZoom'     => 19,
    ],
    // United States only
    'usgs-topo' => [
        'label'       => 'USGS Topo',
        'url'         => 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}',
        'attribution' => 'Tiles courtesy of the <a href="https://www.usgs.gov/">U.S. Geological Survey</a>',
        'maxZoom'     => 16,
    ],
],

foreach ($page->route()->yaml() as $point) {
    echo $point['lat'] . ', ' . $point['lng'];
}

$location = $page->location()->yaml();
echo $location['lat'] . ', ' . $location['lng'];

'tearoom1.leaflet-map.tiles.proxy' => true,

'tearoom1.leaflet-map.loadOnClick' => true,

return [
    'tearoom1.leaflet-map' => [
        'tiles.url'          => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
        'tiles.attribution'  => '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
        'tiles.maxZoom'      => 19,
        'tiles.proxy'        => false,
        'tiles.userAgent'    => 'kirby-leaflet-map (+https://example.com)',
        'loadOnClick'        => false,
        'geocoder'           => true,
        'geocoder.url'       => 'https://nominatim.openstreetmap.org/search',
        'panel.center'       => [20, 0],
        'panel.zoom'         => 2,
        'layers'             => ['default'],
        'icons'              => [],
        'alwaysIncludeAssets' => true,
        'enabled'            => true,
    ],
];