function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } //47.66691, 6.84146 //47.66636, 6.83944 var defaut_latitude = 47.66636; var defaut_longitude = 6.84146; var defautzoom = 14; var init_zoom = 14; defautview = [ defaut_latitude, defaut_longitude]; tmpposition = []; var tmpzoom; var latitude ; var longitude ; var zoom ; if (readCookie("position") !== null ) { tmpposition = (readCookie("position")); tmpzoom = (readCookie("zoom")); var reg=new RegExp("[,]", "g"); var tableau=tmpposition.split(reg); //alert("tmpposition : " + tmpposition + "\n\n tableau[0] = " + tableau[0] + "\n\n tableau[1] = " + tableau[1]); //alert("taille tableau : " + tmpposition.length); var n = tableau[0]; var m = tableau[1]; var positionfinal = [n,m]; defautview = positionfinal; defautzoom = tmpzoom ; } else { defautview = [ defaut_latitude, defaut_longitude]; defautzoom = defautzoom ; } //examples.map-h67hf2ic //examples.map-i86nkdio // //######################################################################################## // Definition de la MAP var map = L.map('map') .setView(defautview , defautzoom).invalidateSize(true) ; L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); //######################################################################################## // declaration des points var coorsField = [{ "type": "Feature", "properties": { "popupContent": "1 - Les bombardements de 1940", "url": 'http://college-valdoie-liberation44.communaute-emg.net/1-les-bombardements/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84135, 47.66178] } } , { "type": "Feature", "properties": { "popupContent": "2 - Pierre Kammerlocher", "url": 'http://college-valdoie-liberation44.communaute-emg.net/2-pierre-kammerlocher/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83992, 47.66115] } } , { "type": "Feature", "properties": { "popupContent": "3 - Anne Frank", "url": 'http://college-valdoie-liberation44.communaute-emg.net/3-anne-frank/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83869, 47.66168] } } , { "type": "Feature", "properties": { "popupContent": "4 - Georges Mercklé", "url": 'http://college-valdoie-liberation44.communaute-emg.net/4-georges-merckle/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83869, 47.66253] } } , { "type": "Feature", "properties": { "popupContent": "5 - Le commandant de Courson", "url": 'http://college-valdoie-liberation44.communaute-emg.net/5-commandant-courson/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83818, 47.66345] } } , { "type": "Feature", "properties": { "popupContent": "6 - René Grandvoinet", "url": 'http://college-valdoie-liberation44.communaute-emg.net/6-rene-grandvoinet/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83688, 47.6659] } } , { "type": "Feature", "properties": { "popupContent": "7 - Victor Heidet", "url": 'http://college-valdoie-liberation44.communaute-emg.net/7-victor-heidet/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.8363, 47.667] } } ,{ "type": "Feature", "properties": { "popupContent": "8 - L'assaut à l'usine Socolest", "url": 'http://college-valdoie-liberation44.communaute-emg.net/8-assaut-usine-socolest/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.8364, 47.66813] } } , { "type": "Feature", "properties": { "popupContent": "9 - Les tombes du Salbert.", "url": 'http://college-valdoie-liberation44.communaute-emg.net/9-les-tombes-du-salbert/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83064, 47.67028] } } , { "type": "Feature", "properties": { "popupContent": "10 - La gare et la résistance fer", "url": 'http://college-valdoie-liberation44.communaute-emg.net/10-la-gare/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83834, 47.66545] } } , { "type": "Feature", "properties": { "popupContent": "11 - Marino Sassi", "url": 'http://college-valdoie-liberation44.communaute-emg.net/11-marino-sassi', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83987, 47.66711] } } , { "type": "Feature", "properties": { "popupContent": "12 - Commandos de Provence", "url": 'http://college-valdoie-liberation44.communaute-emg.net/12-commandos-de-provence/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.8422, 47.6676] } } , { "type": "Feature", "properties": { "popupContent": "13 - Albert Bischoff", "url": 'http://college-valdoie-liberation44.communaute-emg.net/13-albert-bischoff/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84253, 47.66699] } } , { "type": "Feature", "properties": { "popupContent": "14 - Monument aux morts", "url": 'http://college-valdoie-liberation44.communaute-emg.net/14-monument-aux-morts/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84296 , 47.66692] } } , { "type": "Feature", "properties": { "popupContent": "15 - Le carré militaire", "url": 'http://college-valdoie-liberation44.communaute-emg.net/15-le-carre-militaire/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84438 , 47.66803] } } , { "type": "Feature", "properties": { "popupContent": "16 - Le Pont Carnot", "url": 'http://college-valdoie-liberation44.communaute-emg.net/16-le-pont-carnot/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.8422 , 47.66625] } } , { "type": "Feature", "properties": { "popupContent": "17 - Boucherie Poirisse", "url": 'http://college-valdoie-liberation44.communaute-emg.net/17-boucherie-poirisse/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84175 , 47.66529] } } , { "type": "Feature", "properties": { "popupContent": "18 - 'Le château'", "url": 'http://college-valdoie-liberation44.communaute-emg.net/18-le-chateau/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84111,47.66486] } } , { "type": "Feature", "properties": { "popupContent": "19 - Jean Moulin", "url": 'http://college-valdoie-liberation44.communaute-emg.net/19-jean-moulin/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84051,47.66491] } } , { "type": "Feature", "properties": { "popupContent": "20 - Café Sassi", "url": 'http://college-valdoie-liberation44.communaute-emg.net/20-cafe-sassi/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84184,47.66466] } } , { "type": "Feature", "properties": { "popupContent": "21 - Le poste de secours", "url": 'http://college-valdoie-liberation44.communaute-emg.net/21-le-poste-de-secours/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84103,47.66332] } } , { "type": "Feature", "properties": { "popupContent": "22 - Camille Lavigne.", "url": 'http://college-valdoie-liberation44.communaute-emg.net/22-camille-lavigne/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84264,47.66355] } } , { "type": "Feature", "properties": { "popupContent": "23 - Imprimerie Schraag", "url": 'http://college-valdoie-liberation44.communaute-emg.net/23-imprimerie-schraag/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84379,47.66327] } } , { "type": "Feature", "properties": { "popupContent": "24 - André Boulloche", "url": 'http://college-valdoie-liberation44.communaute-emg.net/24-andre-boulloche/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84664,47.66407] } } , { "type": "Feature", "properties": { "popupContent": "25 - Général De Gaulle", "url": 'http://college-valdoie-liberation44.communaute-emg.net/25-general-de-gaulle/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84518,47.66464] } } , { "type": "Feature", "properties": { "popupContent": "26 - Georges Dollfus", "url": 'http://college-valdoie-liberation44.communaute-emg.net/26-georges-dollfus/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84346,47.6658] } } , { "type": "Feature", "properties": { "popupContent": "27 - Les combats du bois d'Arsot", "url": 'http://college-valdoie-liberation44.communaute-emg.net/27-combats-bois-arsot/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84752,47.667] } } , { "type": "Feature", "properties": { "popupContent": "28 - Les trois Dugois", "url": 'http://college-valdoie-liberation44.communaute-emg.net/28-trois-dugois/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84153,47.67038] } } , { "type": "Feature", "properties": { "popupContent": "29 - Maréchal Leclerc", "url": 'http://college-valdoie-liberation44.communaute-emg.net/29-marechal-leclerc/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84263,47.67151] } } , { "type": "Feature", "properties": { "popupContent": "30 - Capitaine Nallet", "url": 'http://college-valdoie-liberation44.communaute-emg.net/30-capitaine-nallet/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84341,47.67226] } } , { "type": "Feature", "properties": { "popupContent": "31 - Frères Marietta", "url": 'http://college-valdoie-liberation44.communaute-emg.net/31-freres-marietta/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84399,47.67294] } } , { "type": "Feature", "properties": { "popupContent": "32 - Les résistants de l'Arsot", "url": 'http://college-valdoie-liberation44.communaute-emg.net/32-emile-marchegay/', "icon": { "iconUrl": 'blue_marker'} }, "geometry": { "type": "Point", "coordinates": [6.8532,47.66119] } } , { "type": "Feature", "properties": { "popupContent": "33 - Les régiments d'Afrique", "url": 'http://college-valdoie-liberation44.communaute-emg.net/33-les-commandos-afrique/', "icon": { "iconUrl": 'green_marker'} }, "geometry": { "type": "Point", "coordinates": [6.85492,47.66126] } } , { "type": "Feature", "properties": { "popupContent": "34 - Joseph Darnand au château Charpentier", "url": 'http://college-valdoie-liberation44.communaute-emg.net/34-joseph-darnand/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83918,47.66893] //47.66893, 6.83918 } } , { "type": "Feature", "properties": { "popupContent": "37 – Rafle rue de Turenne", "url": 'http://college-valdoie-liberation44.communaute-emg.net/37-traque-rue-de-turenne/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.84275,47.67103] //47.67103, 6.84275 } }, { "type": "Feature", "properties": { "popupContent": "36 – Traque rue de la Gare", "url": 'http://college-valdoie-liberation44.communaute-emg.net/36-traque-rue-de-la-gare/', "icon": { "iconUrl": 'brown_marker'} }, "geometry": { "type": "Point", "coordinates": [6.83905,47.66547] //47.66547, 6.83905 } } ]; // declaration des fonctions function onEachFeature(feature, layer) { // var popupContent = "

I started out as a GeoJSON " + // feature.geometry.type + ", but now I'm a Leaflet vector!

"; if (feature.properties && feature.properties.popupContent) { var popupContent = feature.properties.popupContent; } //layer.bindPopup(popupContent); } var coorsLayer = L.geoJson(coorsField, { pointToLayer: function (feature, latlng) { return L.marker(latlng, { icon: L.icon({ iconSize: [20, 30], iconAnchor: [16, 37], popupAnchor: [0, -28], iconUrl: 'files/' + feature.properties.icon.iconUrl + '.png' }) }); }, onEachFeature: onEachFeature }).addTo(map); coorsLayer.on('click', function(e) { clicfeature(); window.parent.location.href = e.layer.feature.properties.url; }); coorsLayer.on('mouseover', function(e) { //open popup; var popup = L.popup({offset: new L.Point(0, - 50)}) .setLatLng(e.latlng) //(assuming e.latlng returns the coordinates of the event) .setContent(e.layer.feature.properties.popupContent) .openOn(map); }); coorsLayer.on('mouseout', function(e) { //open popup; map.closePopup(); }); //######################################################################################## // alert("readcookie : " + readCookie("position")); function onMapClick(e) { var popup2 = L.popup() .setLatLng(e.latlng) .setContent("Vous avez cliqué sur " + e.latlng.toString() + "Zoom = " + map.getZoom()) .openOn(map); } //map.on('click', onMapClick); myLayer.on('click', function(e) { clicfeature(); window.parent.location.href = e.layer.feature.properties.url; }); function clicfeature (){ latitude = map.getCenter().lat; longitude = map.getCenter().lng; zoom = map.getZoom(); createCookie("position",[latitude,longitude] ,3) createCookie("zoom",zoom ,3) $("html, body").animate({ scrollTop: 0 }, 400); } function center_init_map(){ map.setView([ defaut_latitude, defaut_longitude], init_zoom); }