-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
457 additions
and
539 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,36 @@ | ||
{% extends "main.html" %} | ||
|
||
{% block javascript %} | ||
var legend = document.getElementById('legend'); | ||
legend.remove(); | ||
|
||
mapboxgl.accessToken = '{{ accessToken }}'; | ||
|
||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: {{ style }}, | ||
center: {{ center }}, | ||
zoom: {{ zoom }}, | ||
transformRequest: (url, resourceType)=> { | ||
return { | ||
url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') | ||
} | ||
} | ||
}); | ||
|
||
map.addControl(new mapboxgl.NavigationControl()); | ||
|
||
map.on('style.load', function() { | ||
|
||
// Add data source | ||
map.addSource("data", { | ||
"type": "geojson", | ||
"data": {{ geojson_data }}, | ||
"buffer": 1, | ||
"maxzoom": 14 | ||
}); | ||
|
||
// Add data layer | ||
map.addLayer({ | ||
"id": "circle", | ||
"source": "data", | ||
"type": "circle", | ||
"maxzoom": {{ maxzoom }}, | ||
"minzoom": {{ minzoom }}, | ||
"paint": {"circle-radius": 1} | ||
|
||
mapboxgl.accessToken = '{{ accessToken }}'; | ||
|
||
var map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: {{ style }}, | ||
center: {{ center }}, | ||
zoom: {{ zoom }}, | ||
transformRequest: (url, resourceType)=> { | ||
if ( url.slice(0,22) == 'https://api.mapbox.com' ) { | ||
//Add Python Plugin identifier for Mapbox API traffic | ||
return { | ||
url: [url.slice(0, url.indexOf("?")+1), "pluginName=PythonMapboxgl&", url.slice(url.indexOf("?")+1)].join('') | ||
} | ||
} | ||
else { | ||
//Do not transform URL for non Mapbox GET requests | ||
return {url: url} | ||
} | ||
} | ||
}); | ||
|
||
}); | ||
{% block navigation %} | ||
|
||
map.addControl(new mapboxgl.NavigationControl()); | ||
|
||
{% endblock navigation %} | ||
|
||
{% block legend %}{% endblock legend %} | ||
|
||
{% block map %}{% endblock map %} | ||
|
||
{% endblock %} |
This file contains 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
Oops, something went wrong.