Skip to content

Commit 5207744

Browse files
committed
Add support for basemap api keys
1 parent bf5e117 commit 5207744

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

scripts/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ var constants = {
1717
_googleAnalytics: 'Google Analytics Tracking ID',
1818
// Map Settings
1919
_tileProvider: 'Basemap Tiles',
20+
_tileProviderApiKey: 'Basemap Tiles API Key',
2021
_markercluster: 'Cluster Markers',
2122
_introPopupText: 'Intro Popup Text',
2223
_initZoom: 'Initial Zoom',

scripts/map.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,23 @@ $(window).on('load', function() {
926926
* Loads the basemap and adds it to the map
927927
*/
928928
function addBaseMap() {
929+
929930
var basemap = trySetting('_tileProvider', 'CartoDB.Positron');
931+
930932
L.tileLayer.provider(basemap, {
931-
maxZoom: 18
933+
maxZoom: 18,
934+
935+
// Pass the api key to most commonly used parameters
936+
apiKey: trySetting('_tileProviderApiKey', ''),
937+
apikey: trySetting('_tileProviderApiKey', ''),
938+
key: trySetting('_tileProviderApiKey', ''),
939+
accessToken: trySetting('_tileProviderApiKey', '')
932940
}).addTo(map);
941+
933942
L.control.attribution({
934943
position: trySetting('_mapAttribution', 'bottomright')
935944
}).addTo(map);
945+
936946
}
937947

938948
/**

0 commit comments

Comments
 (0)