Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

leaflet_osm_basemaps()

Description

Generates OpenStreetMap basemaps for use in a Leaflet map.

This function defines various tile layers from OpenStreetMap and related providers,
setting properties such as caching, retina display support, maximum zoom levels,
and attribution for each layer.

Parameters

This function accepts no parameters.

Return

string JavaScript code that initializes the OSM basemaps for Leaflet.

Location

include/map_functions.php lines 18 to 88

Definition

 
function leaflet_osm_basemaps() 
    {
    global 
$map_default_cache$map_retina;

    return 
"<!--OpenStreetMap (OSM) basemap group-->
        var osm_attribute = 'Map data © <a href=\"http://openstreetmap.org\">OpenStreetMap</a> contributors';

        var osm_mapnik = L.tileLayer.provider('OpenStreetMap.Mapnik', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 19,
            attribution: osm_attribute
        });

        var osm_de = L.tileLayer.provider('OpenStreetMap.DE', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 18,
            attribution: osm_attribute
        });

        var osm_fr_attribute = '&copy; Openstreetmap France | &copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>';
        var osm_fr = L.tileLayer.provider('OpenStreetMap.France', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 20,
            attribution: osm_fr_attribute
        });

        var osm_ch = L.tileLayer.provider('OpenStreetMap.CH', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 18,
            attribution: osm_attribute
        });

        var osm_bzh = L.tileLayer.provider('OpenStreetMap.BZH', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 19,
            attribution: osm_attribute
        });

        var osm_hot = L.tileLayer.provider('OpenStreetMap.HOT', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 19,
            attribution: osm_attribute
        });

        var osm_hikebike = L.tileLayer.provider('HikeBike.HikeBike', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 19,
            attribution: osm_attribute
        });

        var osm_mtb = L.tileLayer.provider('MtbMap', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            attribution: osm_attribute
        });

        var osm_otm_attribute = 'Map data: &copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>, <a href=\"http://viewfinderpanoramas.org\">SRTM</a> | Map style: &copy; <a href=\"https://opentopomap.org\">OpenTopoMap</a> (<a href=\"https://creativecommons.org/licenses/by-sa/3.0/\">CC-BY-SA</a>)';
        var osm_otm = L.tileLayer.provider('OpenTopoMap', {
            useCache: '" 
. ( $map_default_cache "true" "false" ) . "',
            detectRetina: '" 
. ( $map_retina "true" "false" ) . "',
            maxZoom: 17,
            attribution: osm_otm_attribute
        }); "
;
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 22nd November 2024 15:35 Europe/London time.