Commit 0e796616 authored by Elger Jonker's avatar Elger Jonker

mapbox update, fewer tiles, key to settings


Former-commit-id: 3b6e62a9
parent 0c0f9ed3
......@@ -3,6 +3,8 @@
const failmap = {
map: null, // map showing geographical regions + markers
mapbox_token: '',
polygons: L.geoJson(), // geographical regions
// todo: if you click the group too fast: Marker.js:181 Uncaught TypeError:
// Cannot read property 'createIcon' of undefined
......@@ -50,11 +52,13 @@ const failmap = {
yellowIcon: new L.Icon({iconUrl: 'static/images/yellow-dot.png'}),
grayIcon: new L.Icon({iconUrl: 'static/images/gray-dot.png'}),
initialize: function (country_code, debug) {
initialize: function (mapbox_token, country_code, debug) {
this.mapbox_token = mapbox_token;
// don't name this variable location, because that redirects the browser.
loc = this.initial_location(country_code);
this.map = L.map('map',
{ dragging: !L.Browser.mobile, touchZoom: true, tap: false}
{ dragging: !L.Browser.mobile, touchZoom: true, tap: false, }
).setView(loc.coordinates, loc.zoomlevel);
this.map.scrollWheelZoom.disable();
......@@ -114,7 +118,8 @@ const failmap = {
},
loadTiles: function(){
let tile_uri_base = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png';
// let tile_uri_base = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png';
let tile_uri_base = 'https://api.mapbox.com/styles/v1/mapbox/{style}/tiles/{z}/{x}/{y}/';
let tile_uri_params = 'access_token={accessToken}';
let tile_uri = tile_uri_base + '?' + tile_uri_params;
......@@ -133,7 +138,10 @@ const failmap = {
'Imagery © <a href="http://mapbox.com">Mapbox</a>, ' +
'Ratings &copy; <a href="http://faalkaart.nl/">Fail Map</a> <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-NC-BY-SA</a>',
id: 'mapbox.light',
accessToken: 'pk.eyJ1IjoibXJmYWlsIiwiYSI6ImNqMHRlNXloczAwMWQyd3FxY3JkMnUxb3EifQ.9nJBaedxrry91O1d90wfuw',
accessToken: this.mapbox_token,
style: 'light-v9', // 'dark-v9' for dark mode,
tileSize: 512,
zoomOffset: -1
}).addTo(this.map);
},
......
......@@ -2,6 +2,7 @@
let sentry_token = document.head.querySelector("[name=sentry_token]").getAttribute('content');
let version = document.head.querySelector("[name=version]").getAttribute('content');
let country = document.head.querySelector("[name=country]").getAttribute('content');
let mapbox_token = document.head.querySelector("[name=mapbox_token]").getAttribute('content');
let debug = document.head.querySelector("[name=debug]").getAttribute('content');
if (sentry_token) {
Raven.config(sentry_token, {release: version}).install();
......@@ -325,7 +326,7 @@ var dynamic_translations = function(){
};
let document_ready = function() {
failmap.initialize(country, debug);
failmap.initialize(mapbox_token, country, debug);
views(); // start all vues
lazyload(); // allow for lazy loading of images
......
......@@ -14,6 +14,7 @@
<meta name="version" content="{{ version }}">
<meta name="country" content="{{ country }}">
<meta name="debug" content="{{ debug }}">
<meta name="mapbox_token" content="{{ config.MAPBOX_ACCESS_TOKEN }}">
<title>{% trans "Site Title" %}</title>
......
# urls for scanners, maybe in their own url files
import proxy.views
from django.conf import settings
from constance import config
from django.conf.urls import url
from django.urls import path, register_converter
from django.views.i18n import JavaScriptCatalog
......@@ -60,9 +60,9 @@ urlpatterns = [
# Proxy maptile requests,
# In production this can be done by caching proxy, this makes sure it works for dev. as well.
url(r'^proxy/(?P<url>https://api.tiles.mapbox.com/v4/.*.png$)',
url(r'^proxy/(?P<url>https://api.mapbox.com/styles/v1/mapbox/.*./$)',
proxy.views.proxy_view,
{"requests_args": {"params": {"access_token": settings.MAPBOX_TOKEN}}}),
{"requests_args": {"params": {"access_token": config.MAPBOX_ACCESS_TOKEN}}}),
# translations for javascript files. Copied from the manual.
# https://docs.djangoproject.com/en/2.0/topics/i18n/translation/
......
......@@ -559,8 +559,6 @@ CELERY_WORKER_PREFETCH_MULTIPLIER = 2
# numer of tasks to be executed in parallel by celery
CELERY_WORKER_CONCURRENCY = 10
MAPBOX_TOKEN = "pk.eyJ1IjoibXJmYWlsIiwiYSI6ImNqMHRlNXloczAwMWQyd3FxY3JkMnUxb3EifQ.9nJBaedxrry91O1d90wfuw"
# Settings for statsd metrics collection. Statsd defaults over UDP port 8125.
# https://django-statsd.readthedocs.io/en/latest/#celery-signals-integration
STATSD_HOST = os.environ.get('STATSD_HOST', '127.0.0.1')
......@@ -659,6 +657,9 @@ CONSTANCE_CONFIG = {
'GOOGLE_MAPS_API_KEY': ('AIzaSyBXJbEUxGW1dAB4hJOlmKdYelfoRY6_fjo',
'API Key of google maps that can be used in the game / adding section.', str),
'MAPBOX_ACCESS_TOKEN': ('pk.eyJ1IjoibXJmYWlsIiwiYSI6ImNqMHRlNXloczAwMWQyd3FxY3JkMnUxb3EifQ.9nJBaedxrry91O1d90wfuw',
'Access token for Mapbox', str),
'RESPONSIBLE_ORGANIZATION_NAME': ('', 'The name of the organization running this project.', str),
'RESPONSIBLE_ORGANIZATION_PROMO_TEXT': ('', 'Some text promoting this organization and it\s mission. This text will'
' not be translated.', str),
......@@ -747,7 +748,7 @@ CONSTANCE_CONFIG = {
}
CONSTANCE_CONFIG_FIELDSETS = OrderedDict([
('General', ('COMMENTS', )),
('General', ('COMMENTS', 'MAPBOX_ACCESS_TOKEN')),
('Project', ('PROJECT_NAME', 'PROJECT_COUNTRY', 'PROJECT_TAGLINE', 'PROJECT_WEBSITE', 'PROJECT_MAIL',
'PROJECT_ISSUE_MAIL', 'PROJECT_TWITTER', 'PROJECT_FACEBOOK')),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment