diff --git a/avisstage/static/js/editstage.js b/avisstage/static/js/editstage.js
index 195f195..463b736 100644
--- a/avisstage/static/js/editstage.js
+++ b/avisstage/static/js/editstage.js
@@ -1,4 +1,4 @@
-function initEditStage(STATIC_URL, API_URL) {
+function initEditStage(STATIC_URL, API_URL, MAPBOX_API_KEY) {
var has_changes = true;
var stage_object_id = $("#stage_object_id").val();
$(window).on('beforeunload',
@@ -39,7 +39,7 @@ function initEditStage(STATIC_URL, API_URL) {
var slts = $("select[multiple]").selectize();
// CHOIX DU LIEU
- var lieu_select = new SelectLieuWidget(STATIC_URL, API_URL,
+ var lieu_select = new SelectLieuWidget(STATIC_URL, API_URL, MAPBOX_API_KEY,
$("#lieu_widget"), lieuChoisi);
var avis_lieu_template = $("#avis_lieu_vide").remove().html();
var lieux_liste = $("#lieux-selector");
diff --git a/avisstage/static/js/recherche.js b/avisstage/static/js/recherche.js
index 06a2eaf..d466ff5 100644
--- a/avisstage/static/js/recherche.js
+++ b/avisstage/static/js/recherche.js
@@ -1,4 +1,4 @@
-function InterfaceRecherche(STATIC_ROOT, API_LIEU, ITEMS_URL, lieux) {
+function InterfaceRecherche(STATIC_ROOT, API_LIEU, MAPBOX_API_KEY, ITEMS_URL, lieux) {
var interface_mode, main_container;
var lieux_map = {}, lieux_list = [], stages_map = {}, lieux_db = {};
var stages_db = {};
@@ -83,7 +83,12 @@ function InterfaceRecherche(STATIC_ROOT, API_LIEU, ITEMS_URL, lieux) {
function initCarte() {
if (map !== undefined) return;
map = L.map("carte").panTo([30, 15]).setZoom(1);
- var layer = new L.TileLayer("https://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}", {attribution: 'Map tiles by GIScience Heidelberg'});
+ var layer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
+ maxZoom: 18,
+ id: 'mapbox.streets',
+ accessToken: MAPBOX_API_KEY
+ });
map.addLayer(layer);
$.getJSON(API_LIEU + "set/"+lieux_list.join(';')+"/?format=json", onLoadLieux);
diff --git a/avisstage/static/js/select_lieu.js b/avisstage/static/js/select_lieu.js
index d604d90..ecb4f56 100644
--- a/avisstage/static/js/select_lieu.js
+++ b/avisstage/static/js/select_lieu.js
@@ -1,4 +1,4 @@
-function SelectLieuWidget(STATIC_ROOT, API_LIEU, target, callback) {
+function SelectLieuWidget(STATIC_ROOT, API_LIEU, MAPBOX_API_KEY, target, callback) {
//
// INITIALISATION
@@ -63,12 +63,12 @@ function SelectLieuWidget(STATIC_ROOT, API_LIEU, target, callback) {
// Affiche la carte
map = L.map(map_el[0]).setView([48.8422411,2.3430553], 15);
- var layer = new L.TileLayer(
- "https://korona.geog.uni-heidelberg.de/"
- + "tiles/roads/x={x}&y={y}&z={z}",
- {attribution: 'Map tiles by ' +
- '' +
- 'GIScience Heidelberg'});
+ var layer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
+ maxZoom: 18,
+ id: 'mapbox.streets',
+ accessToken: MAPBOX_API_KEY
+ });
map.addLayer(layer);
map.addLayer(marqueurs);
diff --git a/avisstage/templates/avisstage/detail/stage.html b/avisstage/templates/avisstage/detail/stage.html
index eb79535..d5b3c65 100644
--- a/avisstage/templates/avisstage/detail/stage.html
+++ b/avisstage/templates/avisstage/detail/stage.html
@@ -13,7 +13,12 @@
var STATIC_ROOT = "{{ STATIC_URL|escapejs }}";
function initStageMap(lieux) {
var map = L.map("stage-map");
- var layer = new L.TileLayer("https://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}", {attribution: 'Map tiles by GIScience Heidelberg'});
+ var layer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
+ maxZoom: 18,
+ id: 'mapbox.streets',
+ accessToken: "{{ MAPBOX_API_KEY|escapejs }}"
+ });
map.addLayer(layer);
function makeIcon(couleur){
diff --git a/avisstage/templates/avisstage/formulaires/stage.html b/avisstage/templates/avisstage/formulaires/stage.html
index 554bdfa..abd4934 100644
--- a/avisstage/templates/avisstage/formulaires/stage.html
+++ b/avisstage/templates/avisstage/formulaires/stage.html
@@ -4,7 +4,7 @@
{% block title %}{% if creation %}Nouvelle expérience{% else %}Modification d'une expérience{% endif %}{% endblock %}
{% block extra_head %}
-
+
@@ -22,7 +22,8 @@
$(function(){
initEditStage(
"{{ STATIC_URL|escapejs }}",
- "{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}");
+ "{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}",
+ "{{ MAPBOX_API_KEY|escapejs }}");
});
var django = {};
django.jQuery = $;
diff --git a/avisstage/templates/avisstage/recherche/resultats.html b/avisstage/templates/avisstage/recherche/resultats.html
index e0532ec..ba40785 100644
--- a/avisstage/templates/avisstage/recherche/resultats.html
+++ b/avisstage/templates/avisstage/recherche/resultats.html
@@ -59,6 +59,7 @@
var interfaceRecherche = new InterfaceRecherche(
"{{ STATIC_URL|escapejs }}",
"{% url 'avisstage:api_dispatch_list' resource_name="lieu" api_name="v1" %}",
+ "{{ MAPBOX_API_KEY }}",
"{% url 'avisstage:stage_items' %}",
lieux);
diff --git a/avisstage/views.py b/avisstage/views.py
index 99c03bb..7bccefe 100644
--- a/avisstage/views.py
+++ b/avisstage/views.py
@@ -6,6 +6,7 @@ from django.views.generic import DetailView, ListView
from django.views.generic.edit import UpdateView, CreateView
from django import forms
from django.urls import reverse
+from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required
from braces.views import LoginRequiredMixin
@@ -75,6 +76,10 @@ class StageView(LoginRequiredMixin, DetailView):
return Stage.objects.filter(filtre)
+ def get_context_data(self, *args, **kwargs):
+ context = super().get_context_data(*args, **kwargs)
+ context['MAPBOX_API_KEY'] = settings.MAPBOX_API_KEY
+ return context
# FAQ
def faq(request):
@@ -156,7 +161,9 @@ def manage_stage(request, pk=None):
return render(request, "avisstage/formulaires/stage.html",
{'form': form, 'avis_stage_form': avis_stage_form,
'avis_lieu_formset': avis_lieu_formset,
- 'creation': pk is None, "last_maj": last_maj})
+ 'creation': pk is None, "last_maj": last_maj,
+ 'GOOGLE_API_KEY': settings.GOOGLE_API_KEY,
+ 'MAPBOX_API_KEY': settings.MAPBOX_API_KEY})
# Ajout d'un lieu de stage
#login_required
diff --git a/avisstage/views_search.py b/avisstage/views_search.py
index 029fa71..bedc8a1 100644
--- a/avisstage/views_search.py
+++ b/avisstage/views_search.py
@@ -229,7 +229,8 @@ def recherche_resultats(request):
template_name = 'avisstage/recherche/stage_items.html'
return render(request, template_name,
{"form": form, "stages": stages, "paginator": stageids,
- "tri": tri, "vue": vue, "lieux": lieux})
+ "tri": tri, "vue": vue, "lieux": lieux,
+ "MAPBOX_API_KEY": settings.MAPBOX_API_KEY})
@login_required
@en_scolarite_required
diff --git a/experiENS/settings_base.py b/experiENS/settings_base.py
index 0c8e707..8e7f517 100644
--- a/experiENS/settings_base.py
+++ b/experiENS/settings_base.py
@@ -12,6 +12,8 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
import os
from django.core.urlresolvers import reverse_lazy
+from .secrets import SECRET_KEY, GOOGLE_API_KEY, MAPBOX_API_KEY
+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
diff --git a/experiENS/settings_dev.py b/experiENS/settings_dev.py
index 2ad8463..295def3 100644
--- a/experiENS/settings_dev.py
+++ b/experiENS/settings_dev.py
@@ -1,7 +1,5 @@
from .settings_base import *
-from .secrets import SECRET_KEY
-
DEBUG = True
DATABASES = {
diff --git a/experiENS/settings_prod.py b/experiENS/settings_prod.py
index 5e22813..08306f6 100644
--- a/experiENS/settings_prod.py
+++ b/experiENS/settings_prod.py
@@ -1,7 +1,5 @@
from .settings_base import *
-from .secrets import SECRET_KEY
-
import os, sys
from django.core.urlresolvers import reverse_lazy