1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<title>POIs_Tout_GPX - Version 21.09 24/09/2021</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Map with Leaflet JS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
<!-- Plugin Leaflet issu de https://github.com/danimt/Leaflet.PolylineMeasuredDistance -->
<script src="L.Polyline.measuredDistance.js"></script>
<!-- ============================================================================== -->
<!-- === Fichier POIs_Tout_GPX.js contenant Data === -->
<!-- ============================================================================== -->
<script src="POIs_Tout_GPX.js"></script>
<!-- ============================================================================== -->
<!-- ============================================================================== -->
<script>
// ==========================================================================
// Routines en fichier js externe en prod
// ==========================================================================
// ========================================================================
// Génération d'un élément DIV id=MyId quelconque dans la page HTML
// ========================================================================
function Ajouter_DIV(MyId) {
var body = document.getElementsByTagName("body")[0];
e = document.createElement("div");
e.id = MyId;
e.innerHTML = " ";
body.appendChild(e);
}
// ==========================================================================
// Array des icones possible pour les marqueurs à afficher sur la carte
// ==========================================================================
// Charger les icônes pour les markers (une seule pour ce test)
var wptIcon = L.icon({
WptNum: 7,
iconUrl: "pin-icon-wpt.png",
shadowUrl: "marker-shadow.png",
iconSize: [20, 20],
shadowSize: [30, 30],
iconAnchor: [10, 25],
shadowAnchor: [10, 27],
popupAnchor: [0, -27],
});
// ==========================================================================
// Fin Routines en fichier js externe en prod
// ==========================================================================
var fen = document.getElementsByTagName("html")[0];
var MyEcranW = fen.clientWidth - 50;
var MyEcranH = fen.clientHeight - 20;
// Paramètres de l'Url demandée pour affichage de la page
MyUrl = "";
// var urlParam = ExtraireParam();
// Récupérer les informations voulues dans parametre des url
// MyUrl = 99 > Valeur Argument TraceGPX : POIs_Tout_GPX.htm?TraceGPX = 99
// MyUrl = 0 à n > Valeur Argument traces AAAA-MM-JJ : POIs_Tout_GPX.htm?TraceGPX = 0 à n
// MyUrl = urlParam["TraceGPX"];
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+= OBJET Interrogation sur case cochée overlayMap =+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Pour Test : MyUrl = le numéro de OverlayMap à afficher (Variable date format AAAA-MM-JJ), si 99 il s'agit de "POIs Photos"
// MyUrl = 0 à n : Charge la page avec la bonne trace sans cocher l'overlayMap AAAA-MM-JJ : Raison ?
// MyURL = 99 : Charge la page avec les POIs Photos et coche bien l'overlayMap
// Variable test activé pour reproduire l'anomalie ui n'existe pas avec le code 99 !
MyUrl = "0";
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
var TraceWPT = wpt;
var NewsPOIsName = false;
var MyCircle = "";
// Initialisation compteur de chargement de fichiers
var nLoad = 0;
var ItemPopup = "";
</script>
</head>
<body>
<script>
Ajouter_DIV("oMap");
document.getElementById("oMap").style.height = MyEcranH + "px";
document.getElementById("oMap").style.width = MyEcranW + "px";
document.getElementById("oMap").style.marginLeft = (fen.clientWidth - MyEcranW - 20) / 2 + "px";
var GPX_KM;
// ================================================================================================================
// Fonds de carte gratuite sélectionnées pour iFrame map
// ================================================================================================================
// OSM
var osmUrl = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
var osmAttribution = 'Map data © <a href="http://www.osm.org">OpenStreetMap</a>';
var osmTileLayer = L.tileLayer(osmUrl, { minZoom: 4, maxZoom: 18, attribution: osmAttribution });
var osmFrUrl = "http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png";
// OSM France
var osmFrAttribution = 'Map data © <a href="http://www.osm.org">OpenStreetMap</a>';
var osmFrTileLayer = L.tileLayer(osmFrUrl, { minZoom: 4, maxZoom: 18, attribution: osmFrAttribution });
var osmRoadsUrl = "http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png";
// Construction de la liste des Layers présents
var baseMaps = {
OSM: osmTileLayer,
"OSM France": osmFrTileLayer,
};
var oMap = L.map("oMap").setView([46.82, 2.9], 6);
osmTileLayer.addTo(oMap);
// Préparer layer config object overlayMaps en premier
var overlayMaps = {
// Remplir selon les variables ci-dessous
};
var markers = new L.featureGroup();
for (var n = 0; n < DateGPX.length; n++) {
var Polyline_and_Marker = new L.LayerGroup();
var polyline = L.polyline([trk[n]]).addTo(Polyline_and_Marker);
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+= OBJET de mon Interrogation measuredDistance() =+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
var GPX_KM = new L.Polyline(trk[n]).measuredDistance();
FileGPX[n] = " : Trajet de " + GPX_KM;
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
var temp = DateGPX[n].substr(2, 8).replace("-", "").replace("-", "");
// Construire tableau des seuls WayPoints de(s) trace(s) sélectionnée(s) pour les positionner sur le trace
for (var j = 0; j < wpt.length; j++) {
var item = wpt[j];
if (item[0].substr(0, 6) == temp) {
ItemPopup = item[0] + "<br>" + item[1].toFixed(6) + " - " + item[2].toFixed(6);
marker = new L.marker([item[1], item[2]], { icon: wptIcon }).bindPopup(ItemPopup).addTo(Polyline_and_Marker);
markers.addLayer(marker);
}
overlayMaps["<span style='color:" + getColor(n) + "'>" + DateGPX[n] + "</span>"] = Polyline_and_Marker;
}
trk[n] = polyline;
polyline
.setStyle({
color: getColor(n),
weight: 3,
opacity: 0.8,
})
.on("mouseout", function (e) {
this.setStyle({
weight: 3,
});
})
.on("mouseover", function (e) {
this.setStyle({
weight: 6,
});
})
.on("click", function (e) {
oMap.fitBounds(e.target.getBounds());
});
// permet d'afficher un menu contextuel (non présent dans ce code)...
markers.on("contextmenu", function (e) {
// Mémoriser le numéro de l'icône du tableau POIs_GPS.js pour connaitre l'icône d'origine dans le markerClusterGroup concerné
WptIconNum = String(wptIcon.options.WptNum);
// Bidouille pour retrouver les coordonnées du marker cliqué e.target ne le permet pas !
for (var n = 0; n < wpt.length; n++) {
var item = wpt[n];
// Localiser Wpt_Name lié aux coordonnées du marqueur
if (item[1] == e.latlng.lat && item[2] == e.latlng.lng) {
Wpt_Name = item[0];
}
}
var me_ = e.layer;
// position pour affichage
var pos = {
x: e.originalEvent.pageX,
y: e.originalEvent.pageY,
};
// affiche le context-menu
showContextMenu(me_, pos);
});
}
for (var j = 0; j < wpt.length; j++) {
var item = wpt[j];
ItemPopup = item[0] + "<br>" + item[1].toFixed(6) + " - " + item[2].toFixed(6);
marker = new L.marker([item[1], item[2]], { icon: wptIcon }).bindPopup(ItemPopup);
markers.addLayer(marker);
// }
overlayMaps[POIsGPX] = markers;
}
var layerControl = new L.Control.Layers(baseMaps, overlayMaps, { collapsed: false }).addTo(oMap);
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+= OBJET du Dysfonctionnement oMap.addLayer(trk[MyUrl]) =+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Si Argument TraceGPX provenant de l'url cartes_Vignettes.htm afficher la trace (MyUrl 0 à 98) ou les POIs (MyUrl 99)
if (MyUrl != null || MyUrl != undefined) {
if (MyUrl != "99") {
oMap.addLayer(trk[MyUrl]);
oMap.fitBounds(trk[MyUrl].getBounds());
} else {
oMap.addLayer(markers);
oMap.fitBounds(markers.getBounds());
}
}
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Surveillance du statut des cases à cocher overlays du Control.Layers
oMap.on("overlayadd", function (e) {
if (e.name.indexOf("id=Load") !== -1) {
// Extraire id=Loadnn où nn est le code couleur de la trace du contenu html de l'élément e.name
reg = /id=Load[0-9]{1,3}/g;
res = reg.exec(e.name);
res = String(res).substring(7, 9);
console.log("Fichier : " + e.name);
oMap.fitBounds(e.layer.getBounds());
} else {
// Si ce n'est pas un Overlay commençant par POIs
if (e.name.substr(0, 4) != POIsGPX.substr(0, 4)) {
// Extraire la date AAAA-MM-JJ du contenu html de l'élément e.name
var reg = new RegExp("[0-9]{4}[\\-\\-/][0-9]{2}[\\-\\-/][0-9]{2}", "");
var res = reg.exec(e.name);
for (var n = 0; n < DateGPX.length; n++) {
if (DateGPX[n] == res) {
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+= OBJET de mon Interrogation =+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Affichage informations KM de la trace qui vient d'être sélectionnée et affichée
console.log(e.name + FileGPX[n]);
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
// Zoom sur ce trajet
var bounds = trk[n].getBounds();
oMap.fitBounds(bounds);
}
}
} else {
// Afficher les POIs Photos
console.log("Visualisation de tous les " + e.name);
// Zoom sur les POIs
oMap.fitBounds(markers.getBounds());
}
}
});
oMap.on("overlayremove", function (e) {
// Code pour Reset des informatons affichéers...
});
</script>
</body>
</html> |
Partager