Commit 9904e65b authored by Gérald Niel's avatar Gérald Niel
Browse files

Nouvelle-Calédonie

parent 8089d33a
[
{
"code": "01",
"nom": "Ain"
},
{
"code": "02",
"nom": "Aisne"
},
{
"code": "03",
"nom": "Allier"
},
{
"code": "04",
"nom": "Alpes-de-Haute-Provence"
},
{
"code": "05",
"nom": "Hautes-Alpes"
},
{
"code": "06",
"nom": "Alpes-Maritimes"
},
{
"code": "07",
"nom": "Ardèche"
},
{
"code": "08",
"nom": "Ardennes"
},
{
"code": "09",
"nom": "Ariège"
},
{
"code": "10",
"nom": "Aube"
},
{
"code": "11",
"nom": "Aude"
},
{
"code": "12",
"nom": "Aveyron"
},
{
"code": "13",
"nom": "Bouches-du Rhône"
},
{
"code": "14",
"nom": "Calvados"
},
{
"code": "15",
"nom": "Cantal"
},
{
"code": "16",
"nom": "Charente"
},
{
"code": "17",
"nom": "Charente-Maritime"
},
{
"code": "18",
"nom": "Cher"
},
{
"code": "19",
"nom": "Corrèze"
},
{
"code": "20",
"nom": "Corse"
},
{
"code": "21",
"nom": "Côte-d’or"
},
{
"code": "22",
"nom": "Côtes-d’armor"
},
{
"code": "23",
"nom": "Creuse"
},
{
"code": "24",
"nom": "Dordogne"
},
{
"code": "25",
"nom": "Doubs"
},
{
"code": "26",
"nom": "Drôme"
},
{
"code": "27",
"nom": "Eure"
},
{
"code": "28",
"nom": "Eure-et-Loir"
},
{
"code": "29",
"nom": "Finistère"
},
{
"code": "2A",
"nom": "Corse-du-Sud"
},
{
"code": "2B",
"nom": "Haute-Corse"
},
{
"code": "30",
"nom": "Gard"
},
{
"code": "31",
"nom": "Haute-Garonne"
},
{
"code": "32",
"nom": "Gers"
},
{
"code": "33",
"nom": "Gironde"
},
{
"code": "34",
"nom": "Hérault"
},
{
"code": "35",
"nom": "Ille-et-Vilaine"
},
{
"code": "36",
"nom": "Indre"
},
{
"code": "37",
"nom": "Indre-et-Loire"
},
{
"code": "38",
"nom": "Isère"
},
{
"code": "39",
"nom": "Jura"
},
{
"code": "40",
"nom": "Landes"
},
{
"code": "41",
"nom": "Loir-et-Cher"
},
{
"code": "42",
"nom": "Loire"
},
{
"code": "43",
"nom": "Haute-Loire"
},
{
"code": "44",
"nom": "Loire-Atlantique"
},
{
"code": "45",
"nom": "Loiret"
},
{
"code": "46",
"nom": "Lot"
},
{
"code": "47",
"nom": "Lot-et-Garonne"
},
{
"code": "48",
"nom": "Lozère"
},
{
"code": "49",
"nom": "Maine-et-Loire"
},
{
"code": "50",
"nom": "Manche"
},
{
"code": "51",
"nom": "Marne"
},
{
"code": "52",
"nom": "Haute-Marne"
},
{
"code": "53",
"nom": "Mayenne"
},
{
"code": "54",
"nom": "Meurthe-et-Moselle"
},
{
"code": "55",
"nom": "Meuse"
},
{
"code": "56",
"nom": "Morbihan"
},
{
"code": "57",
"nom": "Moselle"
},
{
"code": "58",
"nom": "Nièvre"
},
{
"code": "59",
"nom": "Nord"
},
{
"code": "60",
"nom": "Oise"
},
{
"code": "61",
"nom": "Orne"
},
{
"code": "62",
"nom": "Pas-de-Calais"
},
{
"code": "63",
"nom": "Puy-de-Dôme"
},
{
"code": "64",
"nom": "Pyrénées-Atlantiques"
},
{
"code": "65",
"nom": "Hautes-Pyrénées"
},
{
"code": "66",
"nom": "Pyrénées-Orientales"
},
{
"code": "67",
"nom": "Bas-Rhin"
},
{
"code": "68",
"nom": "Haut-Rhin"
},
{
"code": "69",
"nom": "Rhône"
},
{
"code": "70",
"nom": "Haute-Saône"
},
{
"code": "71",
"nom": "Saône-et-Loire"
},
{
"code": "72",
"nom": "Sarthe"
},
{
"code": "73",
"nom": "Savoie"
},
{
"code": "74",
"nom": "Haute-Savoie"
},
{
"code": "75",
"nom": "Paris"
},
{
"code": "76",
"nom": "Seine-Maritime"
},
{
"code": "77",
"nom": "Seine-et-Marne"
},
{
"code": "78",
"nom": "Yvelines"
},
{
"code": "79",
"nom": "Deux-Sèvres"
},
{
"code": "80",
"nom": "Somme"
},
{
"code": "81",
"nom": "Tarn"
},
{
"code": "82",
"nom": "Tarn-et-Garonne"
},
{
"code": "83",
"nom": "Var"
},
{
"code": "84",
"nom": "Vaucluse"
},
{
"code": "85",
"nom": "Vendée"
},
{
"code": "86",
"nom": "Vienne"
},
{
"code": "87",
"nom": "Haute-Vienne"
},
{
"code": "88",
"nom": "Vosges"
},
{
"code": "89",
"nom": "Yonne"
},
{
"code": "90",
"nom": "Territoire-de-Belfort"
},
{
"code": "91",
"nom": "Essonne"
},
{
"code": "92",
"nom": "Hauts-de-Seine"
},
{
"code": "93",
"nom": "Seine-Saint-Denis"
},
{
"code": "94",
"nom": "Val-de-Marne"
},
{
"code": "95",
"nom": "Val-d’oise"
},
{
"code": "971",
"nom": "Guadeloupe"
},
{
"code": "972",
"nom": "Martinique"
},
{
"code": "973",
"nom": "Guyane"
},
{
"code": "974",
"nom": "La Réunion"
},
{
"code": "976",
"nom": "Mayotte"
},
{
"code": "98",
"nom": "Nouvelle-Calédonie"
}
]
\ No newline at end of file
......@@ -2,6 +2,7 @@ window.addEventListener('load', async function () {
const center = [46.415, 1.461],
zoom = 6,
metropole = await getJsonAsync('geojson/metropole-et-outre-mer.geojson'),
departements = await getJsonAsync('assets/departements.json'),
ign_attribution = '<a href="https://geoservices.ign.fr/">IGN-F/Geoportail</a>',
ign_options = {
minZoom: 0,
......@@ -123,10 +124,10 @@ window.addEventListener('load', async function () {
const geoCoder = new L.Control.Geocoder.Nominatim({
reverseQueryParams: {
'accept-language': 'fr'
'accept-language': 'fr,fr-FR'
},
geocodingQueryParams: {
'accept-language': 'fr',
'accept-language': 'fr,fr-FR',
'countrycodes': 'FR'
}
}),
......@@ -146,11 +147,14 @@ window.addEventListener('load', async function () {
let cp = postCode.substring(0, 2).toUpperCase();
departementRef = cp == '97' ? postCode.substring(0, 3).toUpperCase() : cp;
}
else if (e.geocode.properties.address.county != null) {
departementRef = getPostcodeByName(e.geocode.properties.address.county)[0].code
else if (a.region == 'Nouvelle-Calédonie') {
departementRef = '98'
}
else if (e.geocode.properties.address.state != null) {
departementRef = getPostcodeByName(e.geocode.properties.address.state)[0].code
else if (a.county != null) {
departementRef = getPostcodeByName(a.county)[0].code
}
else if (a.state != null) {
departementRef = getPostcodeByName(a.state)[0].code
}
createPoint(center.lat, center.lng, e.geocode.html, departementRef);
theMap.setView([center.lat, center.lng], 8);
......@@ -372,20 +376,19 @@ window.addEventListener('load', async function () {
function getReverse( lat, lng ) {
geoCoder.reverse({ 'lat': lat, 'lng': lng }, theMap.options.crs.scale(18), ( r ) => {
console.log(r[0])
let address = r[0] ? r[0].properties.address : undefined,
html = r[0] ? (r[0].html || '') : '';
if ( address != undefined && address.country == 'France' ) {
let cp = address.state == 'Corse' ? '20' : address.postcode.substring(0, 2);
let cp = address.state == 'Corse' ? '20' : (address.postcode ? address.postcode.substring(0, 2) : null);
if (cp == '97') cp = address.postcode.substring(0, 3);
let departementRef = cp == '20' ? (address.county == 'Corse-du-Sud' ? '2A' : '2B') : cp;
if (!departementRef && address.region == 'Nouvelle-Calédonie') departementRef = '98';
createPoint(lat, lng, html, departementRef);
}
});
}
function getPostcodeByName( name ) {
const departements = [{ "code": "01", "nom": "Ain" }, { "code": "02", "nom": "Aisne" }, { "code": "03", "nom": "Allier" }, { "code": "04", "nom": "Alpes-de-Haute-Provence" }, { "code": "05", "nom": "Hautes-Alpes" }, { "code": "06", "nom": "Alpes-Maritimes" }, { "code": "07", "nom": "Ardèche" }, { "code": "08", "nom": "Ardennes" }, { "code": "09", "nom": "Ariège" }, { "code": "10", "nom": "Aube" }, { "code": "11", "nom": "Aude" }, { "code": "12", "nom": "Aveyron" }, { "code": "13", "nom": "Bouches-du Rhône" }, { "code": "14", "nom": "Calvados" }, { "code": "15", "nom": "Cantal" }, { "code": "16", "nom": "Charente" }, { "code": "17", "nom": "Charente-Maritime" }, { "code": "18", "nom": "Cher" }, { "code": "19", "nom": "Corrèze" }, { "code": "20", "nom": "Corse" }, { "code": "21", "nom": "Côte-d’or" }, { "code": "22", "nom": "Côtes-d’armor" }, { "code": "23", "nom": "Creuse" }, { "code": "24", "nom": "Dordogne" }, { "code": "25", "nom": "Doubs" }, { "code": "26", "nom": "Drôme" }, { "code": "27", "nom": "Eure" }, { "code": "28", "nom": "Eure-et-Loir" }, { "code": "29", "nom": "Finistère" }, { "code": "2A", "nom": "Corse-du-Sud" }, { "code": "2B", "nom": "Haute-Corse" }, { "code": "30", "nom": "Gard" }, { "code": "31", "nom": "Haute-Garonne" }, { "code": "32", "nom": "Gers" }, { "code": "33", "nom": "Gironde" }, { "code": "34", "nom": "Hérault" }, { "code": "35", "nom": "Ille-et-Vilaine" }, { "code": "36", "nom": "Indre" }, { "code": "37", "nom": "Indre-et-Loire" }, { "code": "38", "nom": "Isère" }, { "code": "39", "nom": "Jura" }, { "code": "40", "nom": "Landes" }, { "code": "41", "nom": "Loir-et-Cher" }, { "code": "42", "nom": "Loire" }, { "code": "43", "nom": "Haute-Loire" }, { "code": "44", "nom": "Loire-Atlantique" }, { "code": "45", "nom": "Loiret" }, { "code": "46", "nom": "Lot" }, { "code": "47", "nom": "Lot-et-Garonne" }, { "code": "48", "nom": "Lozère" }, { "code": "49", "nom": "Maine-et-Loire" }, { "code": "50", "nom": "Manche" }, { "code": "51", "nom": "Marne" }, { "code": "52", "nom": "Haute-Marne" }, { "code": "53", "nom": "Mayenne" }, { "code": "54", "nom": "Meurthe-et-Moselle" }, { "code": "55", "nom": "Meuse" }, { "code": "56", "nom": "Morbihan" }, { "code": "57", "nom": "Moselle" }, { "code": "58", "nom": "Nièvre" }, { "code": "59", "nom": "Nord" }, { "code": "60", "nom": "Oise" }, { "code": "61", "nom": "Orne" }, { "code": "62", "nom": "Pas-de-Calais" }, { "code": "63", "nom": "Puy-de-Dôme" }, { "code": "64", "nom": "Pyrénées-Atlantiques" }, { "code": "65", "nom": "Hautes-Pyrénées" }, { "code": "66", "nom": "Pyrénées-Orientales" }, { "code": "67", "nom": "Bas-Rhin" }, { "code": "68", "nom": "Haut-Rhin" }, { "code": "69", "nom": "Rhône" }, { "code": "70", "nom": "Haute-Saône" }, { "code": "71", "nom": "Saône-et-Loire" }, { "code": "72", "nom": "Sarthe" }, { "code": "73", "nom": "Savoie" }, { "code": "74", "nom": "Haute-Savoie" }, { "code": "75", "nom": "Paris" }, { "code": "76", "nom": "Seine-Maritime" }, { "code": "77", "nom": "Seine-et-Marne" }, { "code": "78", "nom": "Yvelines" }, { "code": "79", "nom": "Deux-Sèvres" }, { "code": "80", "nom": "Somme" }, { "code": "81", "nom": "Tarn" }, { "code": "82", "nom": "Tarn-et-Garonne" }, { "code": "83", "nom": "Var" }, { "code": "84", "nom": "Vaucluse" }, { "code": "85", "nom": "Vendée" }, { "code": "86", "nom": "Vienne" }, { "code": "87", "nom": "Haute-Vienne" }, { "code": "88", "nom": "Vosges" }, { "code": "89", "nom": "Yonne" }, { "code": "90", "nom": "Territoire-de-Belfort" }, { "code": "91", "nom": "Essonne" }, { "code": "92", "nom": "Hauts-de-Seine" }, { "code": "93", "nom": "Seine-Saint-Denis" }, { "code": "94", "nom": "Val-de-Marne" }, { "code": "95", "nom": "Val-d’oise" },{ "code": "971", "nom": "Guadeloupe" },{ "code": "972", "nom": "Martinique" },{ "code": "973", "nom": "Guyane" },{"code": "974", "nom": "La Réunion"},{ "code": "976", "nom": "Mayotte" }];
return departements.filter( dep => {
return dep.nom == name
});
......
This diff is collapsed.
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