From 7996b141aa9c79e2c1ac0db7fa6be17fe65db5f2 Mon Sep 17 00:00:00 2001 From: PeterTheOne Date: Tue, 2 Aug 2016 21:54:58 +0200 Subject: [PATCH] add tilesurl option for leaflet map --- Maps_Settings.php | 4 ++++ i18n/en.json | 1 + i18n/qqq.json | 1 + includes/services/Leaflet/Maps_Leaflet.php | 6 ++++++ includes/services/Leaflet/jquery.leaflet.js | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Maps_Settings.php b/Maps_Settings.php index e5e6f8d6e..d20f47eeb 100644 --- a/Maps_Settings.php +++ b/Maps_Settings.php @@ -297,5 +297,9 @@ // user does not provide one. $GLOBALS['egMapsLeafletZoom'] = 14; + // String. The default tilesurl for the leaflet map. This value will only be used when the + // user does not provide one. + $GLOBALS['egMapsLeafletTilesurlDefault'] = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + $GLOBALS['egMapsGlobalJSVars'] = []; diff --git a/i18n/en.json b/i18n/en.json index 4c763ee2d..f314c586b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -120,6 +120,7 @@ "maps_googlemaps3": "Google Maps v3", "maps_leaflet": "Leaflet", "maps-leaflet-par-defzoom": "Allows setting the default zoom level of the map.", + "maps-leaflet-par-tilesurl": "Tiles source url for the leaflet map.", "maps_openlayers": "OpenLayers", "maps_click_to_activate": "Click to activate map", "maps_centred_on": "Map centered on $1, $2.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 8fc04741a..26f24437b 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -129,6 +129,7 @@ "maps_googlemaps3": "Lable for a result format on SMW's special page \"Ask\".\n\n{{optional}}", "maps_leaflet": "This is a field label.\n\n{{optional}}", "maps-leaflet-par-defzoom": "{{maps-par|leaflet|defzoom}}", + "maps-leaflet-par-tilesurl": "{{maps-par|leaflet|tilesurl}}", "maps_openlayers": "Lable for a result format on SMW's special page \"Ask\".\n\n{{optional}}", "maps_click_to_activate": "This is an informatory message.", "maps_centred_on": "This is an informatory message.\n\nParameters:\n* $1 - latitude\n* $2 - longitude", diff --git a/includes/services/Leaflet/Maps_Leaflet.php b/includes/services/Leaflet/Maps_Leaflet.php index 71528a608..820bab8ba 100644 --- a/includes/services/Leaflet/Maps_Leaflet.php +++ b/includes/services/Leaflet/Maps_Leaflet.php @@ -44,6 +44,12 @@ public function addParameterInfo( array &$params ) { 'default' => $GLOBALS['egMapsResizableByDefault'], 'message' => 'maps-par-resizable' ]; + + $params['tilesurl'] = [ + 'type' => 'boolean', + 'default' => $GLOBALS['egMapsLeafletTilesurlDefault'], + 'message' => 'maps-leaflet-par-tilesurl' + ]; } /** diff --git a/includes/services/Leaflet/jquery.leaflet.js b/includes/services/Leaflet/jquery.leaflet.js index 8ceef9ecd..041fc5a9f 100644 --- a/includes/services/Leaflet/jquery.leaflet.js +++ b/includes/services/Leaflet/jquery.leaflet.js @@ -153,7 +153,7 @@ this.map = map; // add an OpenStreetMap tile layer - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + L.tileLayer(options.tilesurl, { attribution: '© OpenStreetMap contributors' }).addTo(map);