Created
October 8, 2020 11:20
-
-
Save zertrin/71b61ab2dc175c99103fa108ade5f3cb to your computer and use it in GitHub Desktop.
Git patch for Academic theme v4.8.0 - Update Mapbox API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1f751f8c68c9d67c0108747755d43c4449cd9a43 Mon Sep 17 00:00:00 2001 | |
From: zertrin <[email protected]> | |
Date: Thu, 8 Oct 2020 19:09:54 +0800 | |
Subject: [PATCH] Update Mapbox API | |
--- | |
assets/js/academic.js | 36 +++++++++++++++++++----------------- | |
1 file changed, 19 insertions(+), 17 deletions(-) | |
diff --git a/assets/js/academic.js b/assets/js/academic.js | |
index b2d646e..88be26e 100644 | |
--- a/assets/js/academic.js | |
+++ b/assets/js/academic.js | |
@@ -264,23 +264,25 @@ | |
title: address | |
}) | |
} else { | |
- let map = new L.map('map').setView([lat, lng], zoom); | |
- if (map_provider == 3 && api_key.length) { | |
- L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { | |
- attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', | |
- maxZoom: 18, | |
- id: 'mapbox.streets', | |
- accessToken: api_key | |
- }).addTo(map); | |
- } else { | |
- L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
- maxZoom: 19, | |
- attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' | |
- }).addTo(map); | |
- } | |
- let marker = L.marker([lat, lng]).addTo(map); | |
- let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N'; | |
- marker.bindPopup(address + '<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route=' + url + '">Routing via OpenStreetMap</a></p>'); | |
+ let map = new L.map('map').setView([lat, lng], zoom); | |
+ if ( map_provider == 3 && api_key.length ) { | |
+ L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { | |
+ attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', | |
+ tileSize: 512, | |
+ maxZoom: 18, | |
+ zoomOffset: -1, | |
+ id: 'mapbox/streets-v11', | |
+ accessToken: api_key | |
+ }).addTo(map); | |
+ } else { | |
+ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
+ maxZoom: 19, | |
+ attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' | |
+ }).addTo(map); | |
+ } | |
+ let marker = L.marker([lat, lng]).addTo(map); | |
+ let url = lat + ',' + lng +'#map='+ zoom +'/'+ lat +'/'+ lng +'&layers=N'; | |
+ marker.bindPopup(address + '<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route='+ url +'">Routing via OpenStreetMap</a></p>'); | |
} | |
} | |
} | |
-- | |
2.20.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment