WME MapsFr

This script create buttons to permalink page on several Maps.

// ==UserScript==
// @name            WME MapsFr
// @name:fr         WME MapsFr
// @icon            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAACnCAMAAAAPIrEmAAAB7FBMVEW7u7sFHnC9vb0EHHADHXPR0dG4uLijHimqqqq2trbMzMzW1tbHIzCsrKwAGWyrHinU1NO6IS3OJDHDIi/JycmuHirKIzDFxcUCHHSgHii0tLQBGm2lHymoHynHx8eoqKiiHSeuICu8IS2urq7BwcEDHG+/v78BGGbOz86ysrK3ICywsLDNJDHZ2dnDw8OdICnFIi+/Ii6yHyueHCapICuxIS0CGmm0IS2kHSi4ISwHIHIAGGi1HysSKXegHyqbHigWLXgKInKrICsWMYwZMHwWMIQUL4mgHCa6ICwCGGQEHGoNJHAUK3qmHii+IS0HH20YL3oXMIHc3NwYM4wWMYnCIi+wICudHigNKYMKIm+wHioVLn8NJXUPJnIZMokYMYYOKoYYL3gRKHYFG2aoHSgSLYkUK3cUKnWmpqYOKH8KJX0AHHcLI3UTK30BGm8SKHMIHmoFIHcBF2LBIi4QLIcTLYIRK4EQKHoLImwSLYUPKH0WLXwKJoIFIX/QJDEHInoLJXoGHWgCHnsYM44AF3KvGCS4h4q9xMS+GSfRJDJ9haIAEWKdGiTQ2Nh0fJbLlZmIka+pFyOxgoaEjanAjZHk496me37RJTKXoL7GkZVwd5HSJDLGGyiOl7OSm7nQmJ3UnKDRJTPSJTPTJTIsuLKuAAAjfUlEQVR42qzci1dUVRQG8BuKE5iChRHkjEMiQSYljwSiF5VQK2ilRJaUraJWFLYqDBaWZW8re6nZ+/2P9u3X3ffMucNtqi+kx8y01m++fc49d5KSs5z3kVcoN9xww4cfvsq5UbIzyI3IfmTLVUEmJu5DVhYXn7vrrpVLlT5Kb2/vYGdnpaOjldLP3zsqlUrn4CAe6mtqSvr6mpIk2YYkTU19eDqeTU/tb25ubt+uOYgc/f3n66+//hrK7dchjz++eujQTbtmZsZvQQ4PDQ0tLPS0tb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Qt4x50rPag85XYO1fMTXmKL+SAIyYHHWvd6VjmBqfcK0dGlo+BrvJ4oko5k8v58bjW0o0uyT7/bqdY6O/zHMrp5bhTXtBZObd241BuzdPaKhc65PnmTnot50LP5VE66eVH/6V2pb/SJTe+wSlXeiFn5SE/OYKc8yB0yp2e2wEv5N3jjvC6DjnofmlDXrlP7pcJvuj65EjIbZujnMMudOGaPNIvB/2vH1rliZ7y/LJGOce9oG8a3edd7Qj8pLfK7cbLJied8KRzVq7yxuEIrbVcgq/BqOWgIoTXnbcv9JmKzqfqYsetliK1PHmdgvKczmGv5ScFHumWj2nwNRg/Z3LYI4R3yoNO+SKONCEf7HLIq0inXOgx64mc9HyZnwl4yBtzD+RNl3wOdMqhI53wHjnHnfTNjH61k0454ZDHuJPOa1pZeXRuf3Vh0yHXr8H462eRX/7/cpa+KDs8X5oCXQI56QrtkoNetl4Ou2ii8vjORpZeyptSfgLfAGJypJIT3i5vXeikX8/olCsd0ELucMoRkQd9MOxIUrnLxc3jey2PuNy/AQRyDxe6wAv55VZ50KcpNzo/Am/0D1+9CfpNl7vLzbUcodyu6/nOzlUOuYVbXAln55Sfxt2I9igXuvEhn+ew8wxHuW3u9UJXOlLQ5Z6ZN6FP6bX8rD0oR4LOYQe8kiND5U0pPwH51GF8A8gj8s5i0GOPr+TPU46cH7bQg558WA75EAEdvYccaZdr5wjlQT/tw054JefnhzM56Y3L9ctP/gFc9ELXhFh/OZic9BXS8ZIk6N76zUoeAVrkiPwScrZ+2IcdcMqRVvkRyptarq/o2/e+wG50i8vno3Jkz+THfNo75aDbe42QGx3x1kH/YoCnHGd6kSvd8SonHi9LinwuqzwSdIdTTngtPwc65Hu23kM+r3JrnBscUsmdnstf/hd/KuZ7s5KaoQAAAABJRU5ErkJggg==
// @description     This script create buttons to permalink page on several Maps.
// @description:fr  Ce script crée des boutons pour vous permettre d'accéder à des cartes externes.
// @version         2024.08.15.001
// @match           https://www.waze.com/*/editor*
// @match           https://www.waze.com/editor*
// @match           https://beta.waze.com/*
// @match           https://guichet-adresse.ign.fr/map/*
// @match           https://www.google.fr/?MFR*
// @connect         https://www.google.fr/*
// @grant           none
// @author          TXS
// @namespace       https://greasyfork.org/fr/scripts/438942-wme-mapsfr
// ==/UserScript==

/* global $ */

const MapsFr_version = GM_info.script.version, MapsFr_link = GM_info.script.namespace, MapsFr_Icon = GM_info.script.icon;
let gps,mapsUrl,gz,coord,href,addon,userTabs,navTabs,tabContent,newtab,token,setLayer,citycode;
let village, ville, city, town, county, country, country_code,bbox,postcode,bboxR; // Geojson OSM

setTimeout(()=> {
    if (/cadvil/.test(window.location.href)) { detect_MonTerritoireVille(); }
    else if (/caddep/.test(window.location.href)) { detect_MonTerritoireDep(); }
    else if (/addrue/.test(window.location.href)) { detect_AdresseRue(); }
    else if (/addmairie/.test(window.location.href)) { detect_AdresseMairie(); }
    else if (/servpub/.test(window.location.href)) { detect_ServicePublic(); }
    else if (/gouvrue/.test(window.location.href)) { detect_GouvRue(); }
    else if (/mappystr/.test(window.location.href)) { detect_MappyStreet(); }
    else if (/laposte/.test(window.location.href)) { detect_LaPoste(); }
    else if (/chargemap/.test(window.location.href)) { detect_ChargeMap(); }
    else if (/wiiiz/.test(window.location.href)) { detect_Wiiiz(); }
    else if (/izivia/.test(window.location.href)) { detect_Izivia(); }
    else if (/elect/.test(window.location.href)) { detect_Electromaps(); }
    else if (/villerue/.test(window.location.href)) { detect_VilleRue(); }
    else if (/via/.test(window.location.href)) { detect_Via(); }
    else { console.log("Chargement de WME MapsFR"); }
}, 1000);


function MapsFr_bootstrap() {
    if ('undefined' == typeof __RTLM_PAGE_SCOPE_RUN__) {
        (function page_scope_runner() {
            const my_src = "(" + page_scope_runner.caller.toString() + ")();";
            const script = document.createElement('script');
            script.setAttribute("type", "text/javascript");
            script.textContent = "var __RTLM_PAGE_SCOPE_RUN__ = true;\n" + my_src;
            document.body.appendChild(script);
            setTimeout(function() {
                add_buttons();

            }, 3000);
            return; })(); }
}

// CSS INJECTION
(()=> {
    let mapsCss =
        `

         #Apple {
              background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="14" height="14" fill="currentColor" viewBox="0 0 16 16" opacity=".569" style="margin-bottom: -2px"> <g> <path d="M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902 2.482-.878 2.516.024.034 1.52.087 2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314 11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789 1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0 0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074 2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273 2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386 1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154 1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059 2.238-2.758.347-.79.505-1.217.473-1.282Z"></path> <path d="M11.182.008C11.148-.03 9.923.023 8.857 1.18c-1.066 1.156-.902 2.482-.878 2.516.024.034 1.52.087 2.475-1.258.955-1.345.762-2.391.728-2.43Zm3.314 11.733c-.048-.096-2.325-1.234-2.113-3.422.212-2.189 1.675-2.789 1.698-2.854.023-.065-.597-.79-1.254-1.157a3.692 3.692 0 0 0-1.563-.434c-.108-.003-.483-.095-1.254.116-.508.139-1.653.589-1.968.607-.316.018-1.256-.522-2.267-.665-.647-.125-1.333.131-1.824.328-.49.196-1.422.754-2.074 2.237-.652 1.482-.311 3.83-.067 4.56.244.729.625 1.924 1.273 2.796.576.984 1.34 1.667 1.659 1.899.319.232 1.219.386 1.843.067.502-.308 1.408-.485 1.766-.472.357.013 1.061.154 1.782.539.571.197 1.111.115 1.652-.105.541-.221 1.324-1.059 2.238-2.758.347-.79.505-1.217.473-1.282Z"></path></g></svg>');
              background-repeat: no-repeat;
  	          background-position: left 15px bottom 4px;
           }


          .btnMaps {
              width: 95px;
              height: 24px;
              padding: 1px;
              font-size: 70%;
              border-radius: 6px;
              border: 1px solid #C4C4C4;
              background-color: #E7E7E7;
              font-family: "Arial Bold", Helvetica, sans-serif;
              font-weight: bold;
              -webkit-transform: scale(1);
              transform: scale(1);
              -webkit-transition: .5s ease-in-out;
              transition: .3s ease-in-out;
              position: relative;
              z-index: 1;
          }

          .btnMaps:hover {
              -webkit-transform: scale(1.1);
              transform: scale(1.15);
              z-index: 2;
          }

          .btnShape {
              width: 95px;
              height: 24px;
              padding: 1px;
              font-size: 70%;
              border-radius: 6px;
              border: 1px solid #C4C4C4;
              background-color: #E5413C;
              background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 30 20" xml:space="preserve" height="10" width="20" ><g style= "fill= midnightblue" > <path d="M0 0 L0 20 L10 20 L10 0 Z" /></g> <g fill="white"><path d="M10 0 L10 20 L20 20 L20 0 Z" /></g> <g fill="red" ><path d="M20 0 L20 20 L30 20 L30 0 Z" /></g></svg>');
              background-repeat: no-repeat;
              background-position: left 10px bottom 5px;
              font-family: "Arial Bold", Helvetica, sans-serif;
              font-weight: bold;
              -webkit-transform: scale(1);
              transform: scale(1);
              -webkit-transition: .5s ease-in-out;
              transition: .3s ease-in-out;
              position: relative;
              z-index: 1;
          }

          .btnShape:hover {
              -webkit-transform: scale(1.1);
              transform: scale(1.15);
              z-index: 2;
          }


          .btnMapsIc {
              width: 80px;
              height: 35px;
              padding: 5px;
              border-radius: 6px;
              border: 1px solid #C4C4C4;
              background-color: #E7E7E7;
              -webkit-transform: scale(1);
              transform: scale(1);
              -webkit-transition: .3s ease-in-out;
              transition: .3s ease-in-out;
              position: relative;
              z-index: 1;
          }

          .btnMapsIc:hover {
              -webkit-transform: scale(1.1);
              transform: scale(1.15"); z-index: 2;
          }


                  `;

    let style = document.createElement('style');
    style.type = 'text/css';
    (style.styleSheet) ? style.styleSheet.cssText = mapsCss : style.innerHTML = mapsCss; // IE or Other browsers

    document.getElementsByTagName("head")[0].appendChild( style );
})();

const detect_AdresseIGN =()=> {
    let t = window.location.href.split("?")[1];
    let c = JSON.parse(t);
    let coord = ol.proj.transform([c[0], c[1]], "EPSG:4326", "EPSG:3857");
    console.log(coord);
    map.getView().setCenter(coord);
    map.getView().setZoom(c[2]);
}

const detect_MonTerritoireVille =()=> {
    let t = window.location.href.split("?MFRcadvil")[1];
    let c = JSON.parse(t);
    fetch(`https://api-adresse.data.gouv.fr/reverse/?lon=${c[0]}&lat=${c[1]}`)
        .then(resp => resp.json())
        .then((geocodingResult) => {
        if (geocodingResult.features[0] === undefined) { alert(`Le code postal de la ville n'a pas été dédecté.\rIl faut déplacer la carte plus proche d'une ville, ou utiliser le bouton "Cadastre Dep".`)}
        citycode = (geocodingResult.features[0].properties.citycode);
        mapsUrl = `https://www.monterritoire.fr/${citycode}?lat=${c[1]}&lng=${c[0]}&zoom=${c[2]}`;
        window.open(mapsUrl,'_self');
    });}

const detect_MonTerritoireDep =()=> {
    let t = window.location.href.split("?MFRcaddep")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        postcode = (data.features[0].properties.address.postcode.slice(0, 2))
        mapsUrl = `https://www.monterritoire.fr/${postcode}?lat=${c[1]}&lng=${c[0]}&zoom=${c[2]}`;
        window.open(mapsUrl,'_self');
    });}

const detect_AdresseRue =()=> {
    let t = window.location.href.split("?MFRaddrue")[1];
    let c = JSON.parse(t);
    fetch(`https://api-adresse.data.gouv.fr/reverse/?lon=${c[0]}&lat=${c[1]}`)
        .then(resp => resp.json())
        .then((geocodingResult) => {
        if (geocodingResult.features[0] === undefined) { alert(`Le code postal de la ville n'a pas été dédecté.\rIl faut déplacer la carte plus proche d'une ville.`)}
        citycode = (geocodingResult.features[0].properties.citycode);
        mapsUrl = `https://www.annuaire-mairie.fr/rue-${(geocodingResult.features[0].properties.city)}-${(geocodingResult.features[0].properties.postcode.slice(0, 2))}.html`;
        window.open(mapsUrl,'_self');
    });}

const detect_AdresseMairie =()=> {
    let t = window.location.href.split("?MFRaddmairie")[1];
    let c = JSON.parse(t);
    fetch(`https://api-adresse.data.gouv.fr/reverse/?lon=${c[0]}&lat=${c[1]}`)
        .then(resp => resp.json())
        .then((geocodingResult) => {
        if (geocodingResult.features[0] === undefined) { alert(`Le code postal de la ville n'a pas été dédecté.\rIl faut déplacer la carte plus proche d'une ville.`)}
        citycode = (geocodingResult.features[0].properties.citycode);
        mapsUrl = `https://www.annuaire-mairie.fr/?q=${(geocodingResult.features[0].properties.city)} ${(geocodingResult.features[0].properties.postcode.slice(0, 2))}&sa=Rechercher&cx=1&cof=2&ie=UTF-8`;
        window.open(mapsUrl,'_self');
    });}

const detect_ServicePublic =()=> {
    let t = window.location.href.split("?MFRservpub")[1];
    let c = JSON.parse(t);
    fetch(`https://api-adresse.data.gouv.fr/reverse/?lon=${c[0]}&lat=${c[1]}`)
        .then(resp => resp.json())
        .then((geocodingResult) => {
        if (geocodingResult.features[0] === undefined) { alert(`Le code postal de la ville n'a pas été dédecté.\rIl faut déplacer la carte plus proche d'une ville.`)}
        mapsUrl = `https://lannuaire.service-public.fr/recherche?whoWhat=&where=${(geocodingResult.features[0].properties.postcode)}+${(geocodingResult.features[0].properties.city)}`;
        window.open(mapsUrl,'_self');
    });}

const detect_GouvRue =()=> {
    let t = window.location.href.split("?MFRgouvrue")[1];
    let c = JSON.parse(t);
    fetch(`https://api-adresse.data.gouv.fr/reverse/?lon=${c[0]}&lat=${c[1]}`)
        .then(resp => resp.json())
        .then((geocodingResult) => {
        if (geocodingResult.features[0] === undefined) { alert(`Le code postal de la ville n'a pas été dédecté.\rIl faut déplacer la carte plus proche d'une ville.`)}
        mapsUrl = `https://adresse.data.gouv.fr/base-adresse-nationale/${(geocodingResult.features[0].properties.citycode)}`;
        window.open(mapsUrl,'_self');
    });}

const detect_MappyStreet =()=> {
    let t = window.location.href.split("?MFRmappystr")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        bbox = (data.features[0].bbox)
        mapsUrl = `https://fr.mappy.com/plan#/recherche/categorie/commerce?bbox=${bbox}`;
        window.open(mapsUrl,'_self');
    });}

const detect_Via =()=> {
    let t = window.location.href.split("?MFRvia")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        bbox = (data.features[0].bbox)
    let bbox1 = (data.features[0].bbox[0])
    let bbox2 = (data.features[0].bbox[1])
    let bbox3 = (data.features[0].bbox[2])
    let bbox4 = (data.features[0].bbox[3])
// https://www.viamichelin.fr/?bounds=6.932286251251221~43.53466988423997~6.95129774874878~43.543826115760034&itinerary=&poiCategories=7&withCaravan=true
        mapsUrl = `https://www.viamichelin.fr/?bounds=${bbox1}~${bbox2}~${bbox3}~${bbox4}&itinerary=&poiCategories=7&withCaravan=true`;
        window.open(mapsUrl,'_self');
    });}

const detect_LaPoste =()=> {
    let t = window.location.href.split("?MFRlaposte")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        town = (data.features[0].properties.address.town)
        country_code = (data.features[0].properties.address.country_code)
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        country_code = country_code.toUpperCase()
        mapsUrl = `https://localiser.laposte.fr/?q=${ville}`;
        window.open(mapsUrl,'_self');
    });}

const detect_ChargeMap =()=> {
    let t = window.location.href.split("?MFRchargemap")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        town = (data.features[0].properties.address.town)
        country_code = (data.features[0].properties.address.country_code)
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        country_code = country_code.toUpperCase()
        mapsUrl = `https://fr.chargemap.com/cities/${ville}-${country_code}`;
        window.open(mapsUrl,'_self');
    });}

const detect_Wiiiz =()=> {
    let t = window.location.href.split("?MFRwiiiz")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        town = (data.features[0].properties.address.town)
        country_code = (data.features[0].properties.address.country_code)
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        country_code = country_code.toUpperCase()
        mapsUrl = `https://wiiiz.fr/portal/#/search?address=${ville}&lat=${c[1]}&lng=${c[0]}&type=neighborhood`;
        window.open(mapsUrl,'_self');
    });}

const detect_Electromaps =()=> {
    let t = window.location.href.split("?MFRelect")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}&accept-language=us`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        county = (data.features[0].properties.address.county.toLowerCase())
        town = (data.features[0].properties.address.town)
        country = (data.features[0].properties.address.country.toLowerCase())
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        mapsUrl = `https://www.electromaps.com/fr/stations-de-recharge/${country}/${county}/${ville}/`;
        window.open(mapsUrl,'_self');
    });}

const detect_Izivia =()=> {
    let t = window.location.href.split("?MFRizivia")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}&accept-language=us`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        county = (data.features[0].properties.address.county.toLowerCase())
        town = (data.features[0].properties.address.town)
        country = (data.features[0].properties.address.country.toLowerCase())
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        mapsUrl = `https://izivia.com/carte-bornes-electriques-izivia/bornes-de-recharge-${ville}`;
        window.open(mapsUrl,'_self');
    });}


// Test

const detect_VilleRue =()=> {
    let t = window.location.href.split("?MFRvillerue")[1];
    let c = JSON.parse(t);
    fetch(`https://nominatim.openstreetmap.org/reverse?format=geojson&lon=${c[0]}&lat=${c[1]}&zoom=${c[2]}`)
        .then(resp => resp.json())
        .then((data) => {
        village = (data.features[0].properties.address.village)
        city = (data.features[0].properties.address.city)
        town = (data.features[0].properties.address.town)
        postcode = (data.features[0].properties.address.postcode)
        country_code = (data.features[0].properties.address.country_code)
        if (city === undefined) { city = town}
        if (village === undefined) { ville = city} else { ville = village}
        ville = ville.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '') // Minuscule et sans accent.
        country_code = country_code.toUpperCase()
        mapsUrl = `https://rues.openalfa.fr/${ville}`;
        window.open(mapsUrl,'_self');
    });}



function getQueryString(link, name) {
    let pos = link.indexOf( name ) + name.length;
    let len = link.substr(pos).indexOf('&');
    if (-1 == len) len = link.substr(pos).length;
    return parseFloat(link.substr(pos,len)); }
function getGps(z) {
    let href = document.getElementsByClassName('permalink')[0].href;
    let lon = getQueryString(href, 'lon=');
    let lat = getQueryString(href, 'lat=');
    let zoom = parseInt(getQueryString(href, 'zoomLevel=')) + z;
    return {lon, lat, zoom}; }

function geobretagneZoom(gz) {
    switch (gz)
    {
        case 12:
        case 13:
        case 14: gz = 1400; break;
        case 15: gz = 700; break;
        case 16:
        case 17: gz = 280; break;
        case 18: gz = 140; break;
        case 19: gz = 70; break;
        case 20:
        case 21:
        case 22:
        default: gz = 280; break;
    }
    return gz; }

function GoogleEarthZoom(gz) {
    switch (gz)
    {
        case 12:
        case 13:
        case 14: gz = 7000; break;
        case 15: gz = 3500; break;
        case 16: gz = 1250; break;
        case 17: gz = 800; break;
        case 18: gz = 350; break;
        case 19: gz = 250; break;
        case 20: gz = 200; break;
        case 21:
        case 22:
        default: gz = 1250; break;
    }
    return gz; }

function AppleZoom(gz) {
    switch (gz)
    {
        case 12: gz = 1280; break;
        case 13: gz = 640; break;
        case 14: gz = 320; break;
        case 15: gz = 160; break;
        case 16: gz = 80; break;
        case 17: gz = 40; break;
        case 18: gz = 20; break;
        case 19: gz = 10; break;
        case 20: gz = 5; break;
        case 21: gz = 2.5; break;
        case 22: gz = 1.25; break;
        default: gz = 40; break;
    }
    return gz; }


function add_buttons() {
    let btn1 = $('<button class="btnMaps" title="Google Map" style="background-color:#459BF7">Google</button>');
    btn1.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.com/maps/@${lat},${lon},${zoom}z`;
        window.open(mapsUrl,'_blank');
    });
    let btn2 = $('<button class="btnMaps" title="Cartes Géoportail" style="background-color:#CBFA78" >Géoportail</button>');
    btn2.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        setLayer = 'l0=ORTHOIMAGERY.ORTHOPHOTOS::GEOPORTAIL:OGC:WMTS(1)&l1=GEOGRAPHICALGRIDSYSTEMS.MAPS.BDUNI.J1::GEOPORTAIL:OGC:WMTS(1)&l2=LIMITES_ADMINISTRATIVES_EXPRESS.LATEST::GEOPORTAIL:OGC:WMTS(1)&permalink=yes';
        mapsUrl = `https://www.geoportail.gouv.fr/carte?c=${lon},${lat}&z=${zoom}&${setLayer}`;
        window.open(mapsUrl,'_blank');
    });
    let btn3 = $('<button class="btnMaps" title="Base Adresse Nationale" style="background-color:#E6E4FF">AdresseGouv</button>');
    btn3.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        mapsUrl = `https://adresse.data.gouv.fr/map#${zoom}/${lat}/${lon}`;
        window.open(mapsUrl,'_blank');
    });
    let btn4 = $('<button class="btnMaps" title="Satellites Pro">SatellitesPro</button>');
    btn4.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://satellites.pro/France_map#${lat},${lon},${zoom}`;
        window.open(mapsUrl,'_blank');
    });
    let btn5 = $('<button class="btnMaps" title="Open Street Map">OpenStreetM</button>');
    btn5.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `http://www.openstreetmap.org/#map=${zoom}/${lat}/${lon}`;
        window.open(mapsUrl,'_blank');
    });
    let btn6 = $('<button class="btnMaps" title="Via Michelin">Michelin</button>');
    btn6.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRvia[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });
    let btn7 = $('<button class="btnMaps" title="Carte Here WeGo Satellite">Here WeGo</button>');
    btn7.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://wego.here.com/?map=${lat},${lon},${zoom},satellite`;
        window.open(mapsUrl,'_blank');
    });
    let btn8 = $('<button class="btnMaps" title="Mapillary">Mapillary</button>');
    btn8.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        mapsUrl = `https://www.mapillary.com/app/?lat=${lat}&lng=${lon}&z=${zoom}`;
        window.open(mapsUrl,'_blank');
    });
    let btn9 = $('<button class="btnMaps" title="Mappy Commerces">Mappy</button>');
    btn9.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRmappystr[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });
    let btn10 = $('<button class="btnMaps" title="Tomtom MyDrive">Tomtom</button>');
    btn10.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        mapsUrl = `https://plan.tomtom.com/fr?p=${lat},${lon},${zoom}z`;
        window.open(mapsUrl,'_blank');
    });
    let btn11 = $('<button class="btnMaps" title="Bing Cartes Satellite">Bing</button>');
    btn11.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.bing.com/maps?osid=ef3f0715-2277-4a9d-8706-500556506052&cp=${lat}~${lon}&lvl=${zoom}&sty=h`;
        window.open(mapsUrl,'_blank');
    });
    let btn12 = $('<button class="btnMaps" title="Mapbox Streets">MapboxStr</button>');
    btn12.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        token = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
        mapsUrl = `https://api.mapbox.com/styles/v1/mapbox/streets-v11.html?title=true&access_token=${token}#${zoom}/${lat}/${lon}`;
        window.open(mapsUrl,'_blank');
    });
    let btn13 = $('<button class="btnMaps" title="Mapbox Satellite">MapboxSat</button>');
    btn13.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        token = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
        mapsUrl = `https://api.mapbox.com/styles/v1/mapbox/satellite-v9.html?title=true&access_token=${token}#${zoom}/${lat}/${lon}`;
        window.open(mapsUrl,'_blank');
    });
    let btn14 = $('<button class="btnMaps" title="Epsg Streets">EpsgStr</button>');
    btn14.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://epsg.io/map#srs=4326&x=${lon}&y=${lat}&z=${zoom}&layer=streets`;
        window.open(mapsUrl,'_blank');
    });
    let btn15 = $('<button class="btnMaps"; title="Map Compare" style="background-color:#e8dfc2">MapCompare</button>');
    btn15.click(()=>{
        let {lon, lat, zoom} = getGps(-1);
        setLayer = 'num=4&mt0=viamichelin-map&mt1=osmfr&mt2=google-satellite&mt3=mapy-base';
        mapsUrl = `https://mc.bbbike.org/mc/?lon=${lon}&lat=${lat}&zoom=${zoom}&${setLayer}`;
        window.open(mapsUrl,'_blank');
    });
    let btn16 = $('<button class="btnMaps" title="Google Earth" style="background-color:#74D0F1">GoogleEarth</button>');
    btn16.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        var gz = GoogleEarthZoom(zoom);
        mapsUrl = `https://earth.google.com/web/@${lat},${lon},35.26224333a,${gz}d,35y,0h,29t,0r`;
        window.open(mapsUrl,'_blank');
    });

    let btn18 = $('<button class="btnMaps" title="Cadastre Ville"style="background-color:#E8B027">Cadastre Ville</button>');
    btn18.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRcadvil[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn18b = $('<button class="btnMaps" title="Cadastre Département"style="background-color:#E8D627">Cadastre Dep</button>');
    btn18b.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRcaddep[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });


    let btn20 = $('<button class="btnMaps" title="Annuaire Mairie" style="background-color:#ffb6c1">Marie</button>');
    btn20.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRaddmairie[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn21 = $('<button class="btnMaps" title="Annuaire Mairie - Rues" style="background-color:#F8E0F7">Rues</button>');
    btn21.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRaddrue[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn22 = $('<button class="btnMaps" title="Annuaire Service Public" style="background-color:#6A81FF">ServicePublic</button>');
    btn22.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRservpub[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn23 = $('<button class="btnMaps" id="Apple" alt="Apple Map" title="Apple Map">&nbsp;Apple</button>');
    btn23.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://duckduckgo.com/?q=${lat},${lon}&t=h_&iaxm=maps`;
        window.open(mapsUrl,'_blank');
    });

    let btn24 = $('<button class="btnMaps" title="Adresse Gouv - Rues" style="background-color:#F8E0F7">AdGouv Rues</button>');
    btn24.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRgouvrue[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn25 = $('<button class="btnMaps" title="Cadastre Geobretagne" style="background-color:#FEFEE2">Geobretagne</button>');
    btn25.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        var gz = geobretagneZoom(zoom);
        mapsUrl = `https://geobretagne.fr/mapfishapp/map/80f0b82cd897ed57f72012d5d0fde422?noheader&lon=${lon}&lat=${lat}&radius=${gz}`;
        window.open(mapsUrl,'_blank');
    });


    let btn30 = $('<input class="btnMapsIc" type="image" alt="La Poste" title="La Poste" src="https://upload.wikimedia.org/wikipedia/fr/9/92/La_Poste_logo.png">');
    btn30.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRlaposte[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn31 = $('<input class="btnMapsIc" type="image" alt="Charge Map"  title="Carte des bornes de recharge pour voitures électriques" src="https://fr.chargemap.com/client/chargemap/images/logo-light.svg">');
    btn31.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRchargemap[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn32 = $('<input class="btnMapsIc" type="image" alt="Wiiiz"  title="Carte des bornes de recharge pour voitures électriques" src="https://wiiiz.fr/common/images/svg/logo-wiiiz.svg" >');
    btn32.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRwiiiz[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn33 = $('<input class="btnMapsIc" type="image" alt="Electromaps"  title="Carte des bornes de recharge pour voitures électriques" src="https://uploads-ssl.webflow.com/6278f767c8039e09089ab08c/62aae556d19e952671230c8b_horitzontal-logo.svg" >');
    btn33.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRelect[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn34 = $('<input class="btnMapsIc" type="image" alt="Izivia"  title="Carte des bornes de recharge pour voitures électriques" src="https://izivia.com/wp-content/uploads/2021/10/logo.png" >');
    btn34.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRizivia[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn26 = $('<button class="btnShape" title="Mon Territoire Cadastre - Département" style="background-color:#FFFFFF"> &nbsp;Test</button>');
    btn26.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://www.google.fr/?MFRvillerue[${lon},${lat},${zoom}]`;
        window.open(mapsUrl,'_blank');
    });

    let btn27 = $('<button class="btnMaps" title="Prix des carburants" style="background-color:#F2FFCD">Prix 🚘⛽️</button>');
    btn27.click(()=>{
        let {lon, lat, zoom} = getGps(0);
        mapsUrl = `https://data.opendatasoft.com/explore/dataset/prix-des-carburants-en-france-flux-instantane-v2%40opendatamef/map/?location=${zoom},${lat},${lon}&basemap=jawg.streets`;
        window.open(mapsUrl,'_blank');
    });


    addon = document.createElement("section");
    addon.id = "sidepanel-MapsFr";
    addon.className = "tab-pane";
    addon.innerHTML = '<a title='+ MapsFr_link +' target="_blank" href= '+ MapsFr_link + '> <b>Maps Fr</b><style type="text/css">a:link{text-decoration:none}</style> </a><i> - Version du ' + MapsFr_version + '</i><br>';
    userTabs = document.getElementById('user-info');
    navTabs = document.getElementsByClassName('nav-tabs', userTabs)[0];
    tabContent = document.getElementsByClassName('tab-content', userTabs)[0];
    newtab = document.createElement('li');
    newtab.innerHTML = '<a data-toggle="tab" title="Maps France" href="#sidepanel-MapsFr">\&#127467;&#127479;</a>';
    //  newtab.innerHTML = '<a data-toggle="tab" title="Maps France" href="#sidepanel-MapsFr"> <img src='+ MapsFr_Icon +' alt="MapsFR" width="10" height="10"></a>';
    navTabs.appendChild(newtab);
    tabContent.appendChild(addon);

    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn1); $("#sidepanel-MapsFr").append(btn2); $("#sidepanel-MapsFr").append(btn3);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn4); $("#sidepanel-MapsFr").append(btn5); $("#sidepanel-MapsFr").append(btn6);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn7); $("#sidepanel-MapsFr").append(btn8); $("#sidepanel-MapsFr").append(btn9);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn10); $("#sidepanel-MapsFr").append(btn11); $("#sidepanel-MapsFr").append(btn12);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn13); $("#sidepanel-MapsFr").append(btn14); $("#sidepanel-MapsFr").append(btn15);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn16); $("#sidepanel-MapsFr").append(btn18); $("#sidepanel-MapsFr").append(btn18b);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn20); $("#sidepanel-MapsFr").append(btn21); $("#sidepanel-MapsFr").append(btn22);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn23);$("#sidepanel-MapsFr").append(btn24); $("#sidepanel-MapsFr").append(btn25);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn26);$("#sidepanel-MapsFr").append(btn27);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append('<br>');


    $("#sidepanel-MapsFr").append(btn30);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn31); $("#sidepanel-MapsFr").append(btn32); $("#sidepanel-MapsFr").append(btn33);
    $("#sidepanel-MapsFr").append('<br>');
    $("#sidepanel-MapsFr").append(btn34);
}

MapsFr_bootstrap();