Commit 2883cf71 authored by Hypsug0's avatar Hypsug0
Browse files

Merge branch 'develop' into 'develop'

improve search templates

See merge request !50
parents 5dde6bca 5144b978
......@@ -712,3 +712,42 @@ BS Full screen Modal
.form-inline > * {
margin: 10px 3px !important;
}
#spinner {
margin: auto;
position: absolute;
z-index: 1000;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 40px;
height: 40px;
background-color: #333;
border-radius: 100%;
-webkit-animation: sk-scaleout 1.0s infinite ease-in-out;
animation: sk-scaleout 1.0s infinite ease-in-out;
}
@-webkit-keyframes sk-scaleout {
0% {
-webkit-transform: scale(0)
}
100% {
-webkit-transform: scale(1.0);
opacity: 0;
}
}
@keyframes sk-scaleout {
0% {
-webkit-transform: scale(0);
transform: scale(0);
}
100% {
-webkit-transform: scale(1.0);
transform: scale(1.0);
opacity: 0;
}
}
......@@ -28,9 +28,6 @@ const dataTableLanguage = {
}
};
console.log('!!!dataTableLanguage', dataTableLanguage);
const searchControlOptions = {
url: 'https://nominatim.openstreetmap.org/search?format=json&accept-language=fr-FR&q={s}',
jsonpParam: 'json_callback',
......@@ -45,3 +42,46 @@ const searchControlOptions = {
textCancel: 'Annuler',
textErr: 'Erreur'
};
// Map objects and functions
var dataLoaded = {
metaPlace: false,
Place: false
};
function addSpinner() {
$("#main").append("<div id='spinner'></div>");
}
var displaySpinner = function (dataState) {
var spinner = $('#spinner');
if (!dataState) {
spinner.hide();
} else {
spinner.show();
}
};
var checkLoadStates = function (states) {
if (states.metaPlace && states.Place) {
return false
} else {
return true
}
};
function showDisclaimer() {
var div = document.getElementById("info legend")
div.innerHTML = '<i style="background: #ff4c41"></i><span>Localisation simple</span><br/>';
div.innerHTML += '<i style="background: #8A2BE2"></i><span>Localisation sur un métasite</span><br/>';
div.innerHTML += '<i style="background: #9370DB; border-radius: 0%;"></i><span>Emprise du métasite</span><br/>';
}
function hideDisclaimer() {
var div = document.getElementById("info legend")
div.innerHTML = "<b class='fa fa-info-circle'></b>";
}
......@@ -256,7 +256,7 @@ MAPBOX_TILES = [
# Fond aérien, nécessite un compte MapBox pour obtenir la clé.
(
"Vue satellite (MapBox)",
"https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v9/tiles/256/{z}/{x}/{y}?access_token="
"//api.mapbox.com/styles/v1/mapbox/satellite-streets-v9/tiles/256/{z}/{x}/{y}?access_token="
+ mapboxAPIkey,
"(c) MapBox",
),
......@@ -265,14 +265,14 @@ MAPBOX_TILES = [
IGN_TILES = [ # Fond SCAN IGN, nécessite un compte IGN pour obtenir la clé.
(
"Scan25 IGN",
"https://gpp3-wxs.ign.fr/"
"//gpp3-wxs.ign.fr/"
+ ignAPIkey
+ "/geoportail/wmts?LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}",
"(c) IGN Geoportail",
),
(
"Orthophoto IGN",
"https://gpp3-wxs.ign.fr/"
"//gpp3-wxs.ign.fr/"
+ ignAPIkey
+ "/geoportail/wmts?LAYER=ORTHOIMAGERY.ORTHOPHOTOS&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}",
"(c) IGN Geoportail",
......
......@@ -31,20 +31,9 @@
var placeBaseUrl = '{% url 'sights:place_bbox_search_api' %}';
var metaplaceBaseUrl = '{% url 'sights:metaplace_bbox_search_api' %}';
function showDisclaimer() {
var div = document.getElementById("info legend")
div.innerHTML = '<i style="background: #ff4c41"></i><span>Localisation simple</span><br/>';
div.innerHTML += '<i style="background: #8A2BE2"></i><span>Localisation sur un métasite</span><br/>';
div.innerHTML += '<i style="background: #9370DB; border-radius: 0%;"></i><span>Emprise du métasite</span><br/>';
}
function hideDisclaimer() {
var div = document.getElementById("info legend")
div.innerHTML = "<b class='fa fa-info-circle'></b>";
}
window.addEventListener("map:init", function (event) {
addSpinner();
$('#spinner').hide();
var placeMarkers = L.markerClusterGroup({
chunkedLoading: true,
spiderfyDistanceMultiplier: 3,
......@@ -142,7 +131,8 @@
const loadPlaces = function () {
// Download GeoJSON data with Ajax
placeMarkers.clearLayers();
map.spin(true);
dataLoaded.Place = false;
displaySpinner(checkLoadStates(dataLoaded));
var dataBboxUrl = placeBaseUrl + '?format=json&in_bbox=' + map.getBounds().toBBoxString();
if (cancelPlaceSearchRequest) {
// Cancel the previous request before making a new request
......@@ -204,7 +194,8 @@
console.log('<loadPlace leaflet error>', error);
})
.then(function () {
map.spin(false);
dataLoaded.Place = true;
displaySpinner(checkLoadStates(dataLoaded));
});
}
;
......@@ -213,6 +204,8 @@
// Download GeoJSON data with Axios
let cancelMetaPlaceSearchRequest;
loadMetaPlaces = function () {
dataLoaded.metaPlace = false;
displaySpinner(checkLoadStates(dataLoaded));
metaPlacePolygons.clearLayers()
if (cancelMetaPlaceSearchRequest) {
// Cancel the previous request before making a new request
......@@ -261,6 +254,8 @@
});
metaPlacePolygons.addLayer(metaPlaceLayer).addTo(map);
metaPlacePolygons.bringToBack();
dataLoaded.metaPlace = true;
displaySpinner(checkLoadStates(dataLoaded));
})
.catch(function (error) {
console.log('loadMetaPlace Leaflet error', error);
......@@ -287,6 +282,7 @@
clearTimeout(debounce);
debounce = setTimeout(loadDatas, 1000);
} else {
$('#spinner').hide();
clearLayers();
overlayText.addTo(map);
}
......
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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