{"id":6666,"date":"2019-06-03T10:25:20","date_gmt":"2019-06-03T09:25:20","guid":{"rendered":"https:\/\/belrobotics.andromede.digital\/handlersuche\/"},"modified":"2024-10-09T12:34:44","modified_gmt":"2024-10-09T11:34:44","slug":"handlersuche","status":"publish","type":"page","link":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/","title":{"rendered":"H\u00e4ndlersuche"},"content":{"rendered":"\n<div id=\"app\" class=\"grid-container fluid\" v-cloak>\n  <div v-if=\"loadingData\" class=\"loading-message\">\n    <h2>{{ $t('loading')}}<\/h2>\n  <\/div>\n  <div v-else class=\"grid-x grid-margin-x\">\n    <div id=\"map\" class=\"cell small-12 medium-6 large-8 map\"><\/div>\n    <div class=\"cell small-12 medium-6 large-4 content-container\">\n      <div class=\"search-wrapper\">\n        <input type=\"text\" id=\"searchInput\" :placeholder=\"$t('searchBy')\" \/>\n        <i class=\"search-icon\"><\/i>\n      <\/div>\n      <div v-if=\"loadingResults\">\n        <p>{{ $t('loading') }}<\/p>\n      <\/div>\n      <div v-else>\n        <div v-if=\"filteredDealers.length || filteredDistributors.length\" class=\"partner-list\">\n          <div v-if=\"filteredDealers.length\">\n            <h2 class=\"store-category underlined\">{{ $t('dealers')}}<\/h2>\n            <ul class=\"store-archive\">\n              <li v-for=\"dealer in filteredDealers\" :key=\"dealer.id\" :id=\"`location-${dealer.id}`\">\n                <div :class=\"{ 'active-card': dealer.id === activeLocationId }\" class=\"card\">\n                  <div class=\"card-section\">\n                    <h4 class=\"store-title\">{{ dealer.properties.website_name }}<\/h4>\n                    <div class=\"store-address\">\n                      <span class=\"store-street\">{{ dealer.properties.address }}<\/span><br \/>\n                      <span class=\"store-zip\">\n                        {{ dealer.properties.postal_code + \" \" }}\n                      <\/span>\n                      <span class=\"store-town\">{{ dealer.properties.town }}<\/span><br \/>\n                      <span class=\"store-country\">{{ dealer.properties.country }}<\/span>\n                    <\/div>\n                    <div>\n                      <a :href=\"'https:\/\/www.belrobotics.com\/de-ch\/partner\/?id=' + dealer.id + '&type=dealers' + '&partnername=' + dealer.properties.website_name + '&partnerid=' + dealer.id\" class=\"btn-partner\" target=\"_blank\">{{ $t('partnerSite')}}<\/a>\n                    <\/div>\n                  <\/div>\n                <\/div>\n              <\/li>\n            <\/ul>\n          <\/div>\n          <div v-if=\"filteredDistributors.length\">\n            <h2 class=\"store-category underlined\" v-if=\"filteredDistributors.length > 1\">{{ $t('distributors')}}<\/h2>\n            <h2 class=\"store-category underlined\" v-else>{{ $t('distributor')}}<\/h2>\n            <ul class=\"store-archive\">\n              <li v-for=\"distributor in filteredDistributors\" :key=\"distributor.id\" :id=\"`location-${distributor.id}`\" :class=\"{ 'active-card': distributor.id === activeLocationId }\" class=\"card\">\n                <div class=\"card-section\">\n                  <h4 class=\"store-title\">{{ distributor.properties.website_name }}<\/h4>\n                  <div class=\"store-address\">\n                    <span class=\"store-street\">{{ distributor.properties.address }}<\/span><br \/>\n                    <span class=\"store-zip\">\n                      {{ distributor.properties.postal_code + \" \" }}\n                    <\/span>\n                    <span class=\"store-town\">{{ distributor.properties.town }}<\/span><br \/>\n                    <span class=\"store-country\">{{ distributor.properties.country }}<\/span>\n                  <\/div>\n                  <a :href=\"'https:\/\/www.belrobotics.com\/de-ch\/partner\/?id=' + distributor.id + '&type=distributors' + '&partnername=' + distributor.properties.website_name + '&partnerid=' + distributor.id\" class=\"btn-partner\" target=\"_blank\">{{ $t('partnerSite')}}<\/a>\n                <\/div>\n              <\/li>\n            <\/ul>\n          <\/div>\n        <\/div>\n        <div v-else>\n          <p>{{ $t('noResults')}}<\/p>\n        <\/div>\n      <\/div>\n    <\/div>\n  <\/div>\n<\/div>\n\n<script>\n  console.log(\"Yamabiko Partners v1.4.3\");\n\n    var MAP_API_URL = 'https:\/\/www.belrobotics.com\/wp-content\/plugins\/yamabiko-partners\/cache.php';\n\n  \/**\n   * R\u00e9cup\u00e9rer une valeur depuis la map persistante\n   * @param {string} key - La cl\u00e9 \u00e0 rechercher\n   * @returns {Promise<any|null>} - La valeur associ\u00e9e \u00e0 la cl\u00e9, ou null si la cl\u00e9 n'existe pas\n   *\/\n  async function getFromMap(key) {\n\n    try {\n\n      const response = await fetch(`${MAP_API_URL}?key=${encodeURIComponent(key)}`);\n      if (response.ok) {\n        const rawText = await response.text(); \/\/ Lire la r\u00e9ponse comme texte brut\n        if (rawText.trim() === \"\") {\n            return null;\n        }\n        \/\/console.log(\"rawText = \",rawText);\n        const data = JSON.parse(rawText);\n        return data.value; \/\/ Retourne la valeur trouv\u00e9e\n      } else {\n        console.error('Unexpected error:', response.status);\n        throw new Error('Error fetching data from the map');\n      }\n    } catch (error) {\n      console.error('Error in getFromMap >> ', error);\n      throw error; \/\/ R\u00e9\u00e9met l'erreur si elle est autre qu'un 404\n    }\n  }\n\n  \/**\n   * Ajouter ou mettre \u00e0 jour une valeur dans la map persistante\n   * @param {string} key - La cl\u00e9 \u00e0 ajouter ou mettre \u00e0 jour\n   * @param {string} value - La valeur \u00e0 associer \u00e0 la cl\u00e9\n   * @returns {Promise<boolean>} - Retourne true si l'ajout\/mise \u00e0 jour a r\u00e9ussi, false sinon\n   *\/\n  async function addToMap(key, value) {\n    try {\n      \/\/ Construire l'URL avec les param\u00e8tres key et value\n      const url = `${MAP_API_URL}?key=${encodeURIComponent(key)}&value=${encodeURIComponent(value)}`;\n\n      \/\/ Envoyer une requ\u00eate HTTP GET\n      const response = await fetch(url, {\n        method: 'GET'\n      });\n\n      \/\/ V\u00e9rifier si la requ\u00eate a r\u00e9ussi\n      if (response.ok) {\n          const responseText = await response.text(); \/\/ R\u00e9cup\u00e9rer le texte de la r\u00e9ponse\n          console.log(`Key \"${key}\" successfully added\/updated. Info: ${responseText}`);\n        \n        return true; \/\/ Succ\u00e8s\n      } else {\n        const error = await response.json();\n        console.error(`Failed to add\/update key \"${key}\":`, error.error || 'Unknown error');\n        return false; \/\/ \u00c9chec\n      }\n    } catch (error) {\n      console.error('Error in addToMap:', error);\n      return false; \/\/ \u00c9chec d\u00fb \u00e0 une erreur r\u00e9seau ou autre\n    }\n  }\n\n  async function fetchSortOrder() {\n    try {\n      const response = await fetch('\/wp-content\/plugins\/yamabiko-partners\/sort_order.json');\n      if (!response.ok) return {};\n      return await response.json();\n    } catch (e) {\n      console.error('Failed to fetch sort order JSON:', e);\n      return {};\n    }\n  }\n\n  function sortEntitiesByManualOrder(entities, manualOrder) {\n    if (!Array.isArray(manualOrder) || manualOrder.length === 0) return entities.slice().sort((a, b) => {\n      \/\/ fallback: alphabetic by website_name\n      return (a.properties.website_name || '').localeCompare(b.properties.website_name || '');\n    });\n    \/\/ Ensure all IDs are strings for comparison\n    const idToEntity = Object.fromEntries(entities.map(e => [String(e.id), e]));\n    const ordered = manualOrder.map(id => idToEntity[String(id)]).filter(Boolean);\n    const remaining = entities.filter(e => !manualOrder.map(String).includes(String(e.id)));\n    remaining.sort((a, b) => (a.properties.website_name || '').localeCompare(b.properties.website_name || ''));\n    return [...ordered, ...remaining];\n  }\n\n  function initBelPartners() {\n    const {\n      createApp,\n      onMounted\n    } = Vue;\n    const {\n      createI18n,\n      useI18n\n    } = VueI18n;\n\n    async function loadLocaleMessages() {\n      const path = \"\/wp-content\/plugins\/yamabiko-partners\/locales\/\";\n      const enLocale = await fetch(path + \"en.json\").then((res) =>\n        res.json()\n      );\n      const frLocale = await fetch(path + \"fr.json\").then((res) =>\n        res.json()\n      );\n      const csLocale = await fetch(path + \"cs.json\").then((res) =>\n        res.json()\n      );\n      const daLocale = await fetch(path + \"da.json\").then((res) =>\n        res.json()\n      );\n      const deLocale = await fetch(path + \"de.json\").then((res) =>\n        res.json()\n      );\n      const gaLocale = await fetch(path + \"ga.json\").then((res) =>\n        res.json()\n      );\n      const esLocale = await fetch(path + \"es.json\").then((res) =>\n        res.json()\n      );\n      const itLocale = await fetch(path + \"it.json\").then((res) =>\n        res.json()\n      );\n      const nlLocale = await fetch(path + \"nl.json\").then((res) =>\n        res.json()\n      );\n      const nbLocale = await fetch(path + \"nb.json\").then((res) =>\n        res.json()\n      );\n      const plLocale = await fetch(path + \"pl.json\").then((res) =>\n        res.json()\n      );\n      const skLocale = await fetch(path + \"sk.json\").then((res) =>\n        res.json()\n      );\n      const svLocale = await fetch(path + \"sv.json\").then((res) =>\n        res.json()\n      );\n      const fiLocale = await fetch(path + \"fi.json\").then((res) =>\n        res.json()\n      );\n      const roLocale = await fetch(path + \"ro.json\").then((res) =>\n        res.json()\n      );\n      return {\n        en: enLocale,\n        fr: frLocale,\n        cs: csLocale,\n        da: daLocale,\n        de: deLocale,\n        ga: gaLocale,\n        es: esLocale,\n        it: itLocale,\n        nl: nlLocale,\n        nb: nbLocale,\n        pl: plLocale,\n        sk: skLocale,\n        sv: svLocale,\n        fi: fiLocale,\n        ro: roLocale,\n      };\n    }\n\n    loadLocaleMessages().then((messages) => {\n      const i18n = createI18n({\n        locale: document\n          .querySelector(\"html\")\n          .getAttribute(\"lang\")\n          .slice(0, 2),\n        fallbackLocale: \"en\",\n        messages,\n      });\n\n      const app = createApp({\n        data() {\n          return {\n            dealers: [],\n            distributors: [],\n            map: null,\n            markers: [],\n            currentMarkers: [],\n            searchResults: [],\n            filteredDealers: [],\n            filteredDistributors: [],\n            activeLocationId: null,\n            currentCountry: null,\n            search: \"\",\n            loadingData: true,\n            loadingResults: true,\n            dealersLoaded: false,\n            distributorsLoaded: false,\n          };\n        },\n        methods: {\n          async fetchDealers() {\n            try {\n              const url = \"\/wp-json\/bel-dealers\/v1\/dealers\"\n              const response = await fetch(url);\n              if (!response.ok) {\n                throw new Error(\"network error\");\n              }\n              const data = await response.json();\n              this.dealers = data.map((dealer) => ({\n                ...dealer,\n                type: \"dealer\",\n              }));\n            } catch (error) {\n              console.error(error);\n            } finally {\n              this.dealersLoaded = true;\n              this.checkDataLoadingStatus();\n            }\n          },\n          async fetchDistributors() {\n            try {\n              const url = \"\/wp-json\/bel-dealers\/v1\/distributors\";\n              const response = await fetch(url);\n              if (!response.ok) {\n                throw new Error(\"network error\");\n              }\n              const data = await response.json();\n              this.distributors = data.map((distributor) => ({\n                ...distributor,\n                type: \"distributor\",\n              }));\n            } catch (error) {\n              console.error(error);\n            } finally {\n              this.distributorsLoaded = true;\n              this.checkDataLoadingStatus();\n            }\n          },\n          checkDataLoadingStatus() {\n            if (this.dealersLoaded && this.distributorsLoaded) {\n              this.loadingData = false;\n              this.$nextTick(() => {\n                const mapElement = document.getElementById('map');\n                if (mapElement) {\n                  this.initMap();\n                } else {\n                  console.error(\"L'\u00e9l\u00e9ment #map n'a pas pu \u00eatre trouv\u00e9\");\n                }\n\n                const searchInputElement = document.getElementById('searchInput');\n                if (searchInputElement instanceof HTMLInputElement) {\n                  this.initSearchInput();\n                } else {\n                  console.error(\"L'\u00e9l\u00e9ment #searchInput n'est pas un \u00e9l\u00e9ment HTMLInputElement\");\n                }\n              });\n            }\n          },\n          initMap() {\n            this.map = new google.maps.Map(document.getElementById(\"map\"), {\n              center: {\n                lat: 30.0,\n                lng: 30.0\n              },\n              zoom: 3,\n              streetViewControl: false,\n            });\n\n            google.maps.event.addListenerOnce(this.map, 'idle', () => {\n              this.displayMarkersFromLanguage();\n            });\n          },\n          async displayMarkersFromLanguage() {\n            const langHTML = document.querySelector(\"html\").lang;\n\n            \/\/ Si la langue est exactement \"en\", afficher tous les dealers et distributeurs\n            if (langHTML === \"en\") {\n              this.filteredDealers = this.dealers;\n              this.filteredDistributors = this.distributors;\n            } else {\n              const language = document.querySelector(\"html\").getAttribute(\"lang\").slice(0, 2);\n              let regionCode;\n              if (langHTML.length === 5) {\n                regionCode = langHTML.split(\"-\")[1]?.toUpperCase() || null;\n              } else {\n                \/\/ If only language provided (e.g., \"pl\"), assume region code equals uppercased language\n                regionCode = langHTML.toUpperCase();\n              }\n\n              if (regionCode) {\n                const regionNames = new Intl.DisplayNames([language], { type: \"region\" });\n                const countryFullName = regionNames.of(regionCode);\n                if (!countryFullName) {\n                  \/\/ Fallback: show all if region code can't be resolved\n                  this.filteredDealers = this.dealers;\n                  this.filteredDistributors = this.distributors;\n                } else {\n                  const { nearbyEntities } = await this.filterNearbyEntities(countryFullName);\n                  const sortOrder = await fetchSortOrder();\n                  const countryKey = (this.normalizeCountryName(countryFullName || regionCode || '') || '').toLowerCase().trim();\n                  const manualDealerOrder = (sortOrder[countryKey] && sortOrder[countryKey].dealers) || [];\n                  const manualDistributorOrder = (sortOrder[countryKey] && sortOrder[countryKey].distributors) || [];\n                  console.log('Country key for sort:', countryKey, 'Manual dealer order:', manualDealerOrder);\n                  this.filteredDealers = sortEntitiesByManualOrder(\n                    nearbyEntities.filter((e) => e.type === \"dealer\"),\n                    manualDealerOrder\n                  );\n                  this.filteredDistributors = sortEntitiesByManualOrder(\n                    nearbyEntities.filter((e) => e.type === \"distributor\"),\n                    manualDistributorOrder\n                  );\n                }\n              } else {\n                this.filteredDealers = this.dealers;\n                this.filteredDistributors = this.distributors;\n              }\n            }\n\n            await this.addMarkers();\n            this.centerMapOnMarkers();\n            this.loadingResults = false;\n          },\n          async filterDealersAndDistributorsByCountry(countryName) {\n            this.filteredDealers = this.dealers.filter(\n              (dealer) => dealer.properties.country === countryName\n            );\n            this.filteredDistributors = this.distributors.filter(\n              (distributor) => distributor.properties.country === countryName\n            );\n            await this.addMarkers();\n          },\n          async addMarkers() {\n            this.removeMarkers();\n            const locations = [...this.filteredDealers, ...this.filteredDistributors];\n            const bounds = new google.maps.LatLngBounds();\n\n            const infoWindow = new google.maps.InfoWindow();\n\n            const markersPromises = locations.map(async (location) => {\n              const address = `${location.properties.address}, ${location.properties.postal_code} ${location.properties.town}, ${location.properties.country}`;\n              try {\n\n                  result = await this.geocodeAddress(address);\n\n\n                const infoContent = `\n                  <div class=\"map-info-window\">\n                    <h4>${location.properties.website_name}<\/h4>\n                    <div class=\"address\">\n                      <p>${location.properties.address}<br>\n                      ${location.properties.postal_code} ${location.properties.town}<br>\n                      ${location.properties.country}<\/p>\n                    <\/div>\n                  <\/div>\n                `;\n\n                return {\n                  marker: new google.maps.Marker({\n                    position: result,\n                    map: this.map,\n                    title: location.properties.dealer || location.properties.distributor,\n                    icon: location.type === 'distributor' ?\n                      'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-orange-outline.svg' : 'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-green-outline.svg'\n                  }),\n                  location,\n                  result,\n                  infoContent\n                };\n              } catch (error) {\n                console.error(\"Geocoding failed:\", error);\n                return null;\n              }\n            });\n\n            const markersResults = await Promise.all(markersPromises);\n            const validMarkers = markersResults.filter(result => result !== null);\n\n            validMarkers.forEach(({\n              marker,\n              location,\n              result,\n              infoContent\n            }) => {\n              marker.normalIcon = location.type === 'distributor' ?\n                'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-orange-outline.svg' :\n                'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-green-outline.svg';\n              marker.outlineIcon = location.type === 'distributor' ?\n                'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-orange.svg' :\n                'https:\/\/www.belrobotics.com\/wp-content\/themes\/belrobotics\/img\/map-icon-green.svg';\n\n              marker.addListener(\"mouseover\", () => {\n                infoWindow.setContent(infoContent);\n                infoWindow.open(this.map, marker);\n              });\n\n              marker.addListener(\"mouseout\", () => {\n                infoWindow.close();\n              });\n\n              marker.addListener(\"click\", () => {\n                this.markers.forEach(m => {\n                  m.setIcon(m.normalIcon);\n                });\n                marker.setIcon(marker.outlineIcon);\n                this.activeLocationId = location.id;\n                this.scrollToCard(location.id);\n              });\n\n              this.markers.push(marker);\n              bounds.extend(result);\n            });\n\n            if (this.markers.length > 0) {\n              this.map.fitBounds(bounds);\n            }\n          },\n          removeMarkers() {\n            for (const marker of this.markers) {\n              marker.setMap(null);\n            }\n            this.markers = [];\n\n            const currentCenter = this.map.getCenter();\n            const currentZoom = this.map.getZoom();\n\n            this.map = new google.maps.Map(document.getElementById(\"map\"), {\n              center: currentCenter,\n              zoom: currentZoom,\n              streetViewControl: false,\n            });\n          },\n            _geoCodeAdressPromise(address) {\n                return new Promise((resolve, reject) => {\n                    const geocoder = new google.maps.Geocoder();\n                    geocoder.geocode({ address }, (results, status) => {\n                        if (status === \"OK\" && results && results[0]) {\n                            const loc = results[0].geometry.location;\n                            \/\/ Return plain literal for safe JSON serialization\n                            resolve({ lat: typeof loc.lat === 'function' ? loc.lat() : loc.lat, lng: typeof loc.lng === 'function' ? loc.lng() : loc.lng });\n                        } else {\n                            reject(status);\n                        }\n                    });\n                });\n            },\n            async geocodeAddress(address) {\n              let cached = await getFromMap(address);\n              if (cached == null) {\n                  try {\n                    const computed = await this._geoCodeAdressPromise(address);\n                    await addToMap(address, JSON.stringify(computed));\n                    return computed;\n                  } catch (e) {\n                    console.error('Geocoding failed (compute):', e);\n                    throw e;\n                  }\n              }\n\n              \/\/ Parse cached value robustly\n              try {\n                if (typeof cached === 'string') {\n                  try { cached = decodeURIComponent(cached); } catch (_) {}\n                  const parsed = JSON.parse(cached);\n                  if (parsed && typeof parsed.lat === 'number' && typeof parsed.lng === 'number') {\n                    return parsed;\n                  }\n                } else if (typeof cached === 'object' && cached !== null) {\n                  if (typeof cached.lat === 'number' && typeof cached.lng === 'number') {\n                    return cached;\n                  }\n                }\n              } catch (e) {\n                console.error('Failed to parse cached geocode value:', e);\n              }\n\n              \/\/ Fallback: re-geocode and overwrite cache\n              try {\n                const recomputed = await this._geoCodeAdressPromise(address);\n                await addToMap(address, JSON.stringify(recomputed));\n                return recomputed;\n              } catch (e) {\n                console.error('Geocoding failed (fallback):', e);\n                throw e;\n              }\n          },\n          initSearchInput() {\n            this.$nextTick(() => {\n              const searchInput = document.getElementById(\"searchInput\");\n              if (searchInput instanceof HTMLInputElement) {\n                const autocomplete = new google.maps.places.Autocomplete(searchInput, {\n                  types: [\"(regions)\"],\n                  componentRestrictions: {\n                    country: []\n                  }\n                });\n\n                autocomplete.addListener(\"place_changed\", () => {\n                  const place = autocomplete.getPlace();\n                  if (place && place.formatted_address) {\n                    const searchTerm = place.formatted_address;\n                    this.searchLocations(searchTerm);\n                    this.search = searchTerm;\n                  }\n                });\n              } else {\n                console.error(\"L'\u00e9l\u00e9ment #searchInput n'est pas un \u00e9l\u00e9ment HTMLInputElement\");\n              }\n            });\n          },\n          async searchLocations(searchTerm = \"\") {\n            const searchInput = document.getElementById(\"searchInput\");\n            const term = searchTerm ?\n              searchTerm.toString().trim() :\n              searchInput.value.trim();\n            this.removeMarkers();\n\n            if (term) {\n              const {\n                nearbyEntities,\n                location\n              } =\n              await this.filterNearbyEntities(term);\n\n              this.filteredDealers = nearbyEntities.filter(\n                (e) => e.type === \"dealer\"\n              );\n              this.filteredDistributors = nearbyEntities.filter(\n                (e) => e.type === \"distributor\"\n              );\n\n              this.removeMarkers();\n              await this.addMarkers();\n\n              if (location) {\n                \/\/ this.map.panTo(location);\n                \/\/ this.map.setZoom(6);\n                this.map.setCenter(location);\n                this.map.setZoom(10);\n                this.centerMapOnMarkers();\n                const searchMarker = new google.maps.Marker({\n                  map: this.map,\n                  position: location,\n                  title: this.searchTerm,\n                  icon: \"http:\/\/maps.google.com\/mapfiles\/ms\/icons\/orange-dot.png\",\n                });\n              } else {\n                this.centerMapOnMarkers();\n              }\n            } else {\n              this.filteredDealers = this.dealers;\n              this.filteredDistributors = this.distributors;\n              this.removeMarkers();\n              await this.addMarkers();\n              this.centerMapOnMarkers();\n            }\n          },\n          centerMapOnMarkers() {\n            if (this.markers.length > 0) {\n              const bounds = new google.maps.LatLngBounds();\n              for (const marker of this.markers) {\n                bounds.extend(marker.getPosition());\n              }\n              this.map.fitBounds(bounds);\n\n              const maxZoom = 8;\n              if (this.map.getZoom() > maxZoom) {\n                this.map.setZoom(maxZoom);\n              }\n            }\n          },\n          normalizeCountryName(country) {\n            if (!country) return '';\n            country = country.trim();\n            \/\/ Remove anything in parentheses, e.g., \"Polska (PL)\"\n            country = country.replace(\/\\s*\\(.*\\)\\s*\/g, '').toLowerCase();\n            \/\/ If ISO code provided (e.g., \"PL\"), expand to English name\n            if (country.length === 2) {\n              try {\n                const regionNamesEn = new Intl.DisplayNames(['en'], { type: 'region' });\n                const expanded = regionNamesEn.of(country.toUpperCase());\n                if (expanded) {\n                  country = expanded.toLowerCase();\n                }\n              } catch (e) {\n                \/\/ noop\n              }\n            }\n            const countryMapping = {\n              \"netherlands\": [\"netherlands\", \"nederlands\", \"pays-bas\", \"hollande\", \"the netherlands\", \"nl\"],\n              \"ireland\": [\"ireland\", \"republic of ireland\", \"\u00e9ire\", \"irlande\", \"eire\", \"ie\"],\n              \"united kingdom\": [\"united kingdom\", \"uk\", \"great britain\", \"royaume-uni\", \"gb\", \"en\"],\n              \"czech republic\": [\"\u010desko\", \"czech republic\", \"\u010desk\u00e1 republika\", \"\u010de\u0161tina\", \"czechia\", \"r\u00e9publique tch\u00e8que\", \"czech\", \"cz\"],\n              \"belgium\": [\"belgium\", \"belgique\", \"belgi\u00eb\", \"belgien\", \"be\"],\n              \"france\": [\"france\", \"r\u00e9publique fran\u00e7aise\", \"fr\"],\n              \"germany\": [\"germany\", \"deutschland\", \"allemagne\", \"de\"],\n              \"spain\": [\"spain\", \"espa\u00f1a\", \"espagne\", \"es\"],\n              \"italy\": [\"italy\", \"italia\", \"italie\", \"it\"],\n              \"poland\": [\"poland\", \"polska\", \"polski\", \"pologne\", \"pl\"],\n              \"slovakia\": [\"slovakia\", \"slovensko\", \"slovaquie\", \"sk\"],\n              \"sweden\": [\"sweden\", \"sverige\", \"su\u00e8de\", \"se\"],\n              \"norway\": [\"norway\", \"norge\", \"norv\u00e8ge\", \"no\"],\n              \"denmark\": [\"denmark\", \"danmark\", \"danemark\", \"dk\"],\n              \"finland\": [\"finland\", \"suomi\", \"finlande\", \"fi\"],\n              \"luxembourg\": [\"luxembourg\", \"luxemburg\", \"letzebuerg\", \"lu\"]\n            };\n            for (const [standardName, variations] of Object.entries(countryMapping)) {\n              if (variations.includes(country)) {\n                return standardName;\n              }\n            }\n            return country;\n          },\n          async filterNearbyEntities(searchTerm) {\n            const geocoder = new google.maps.Geocoder();\n            return new Promise((resolve) => {\n              geocoder.geocode({ address: searchTerm }, (results, status) => {\n                if (status === \"OK\" && results.length > 0) {\n                  const location = results[0].geometry.location;\n                  const country = results[0].address_components.find((component) => component.types.includes(\"country\"))?.long_name;\n                  const normalizedSearchCountry = this.normalizeCountryName(country);\n\n                  \/\/ Filtrer uniquement par pays, ne pas g\u00e9ocoder chaque entit\u00e9 ici\n                  const nearbyEntities = [...this.dealers, ...this.distributors].filter((entity) => {\n                    const entityCountry = this.normalizeCountryName(entity.properties.country);\n                    return entityCountry === normalizedSearchCountry;\n                  });\n\n                  resolve({ nearbyEntities, location });\n                } else {\n                  console.error(\"Le g\u00e9ocodage n'a pas r\u00e9ussi:\", status);\n                  resolve({ nearbyEntities: [], location: null });\n                }\n              });\n            });\n          },\n          scrollToCard(locationId) {\n            this.$nextTick(() => {\n              const element = document.getElementById(`location-${locationId}`);\n              const container = document.querySelector(\".partner-list\");\n              if (element && container) {\n                container.scrollTo({\n                  top: element.offsetTop - container.offsetTop,\n                  behavior: \"smooth\",\n                });\n              }\n            });\n          },\n        },\n        async mounted() {\n          await this.fetchDealers();\n          await this.fetchDistributors();\n        }\n      });\n\n      app.use(i18n);\n      app.mount(\"#app\");\n    });\n  }\n\n  function checkDependencies() {\n    if (window.Vue && window.google && window.google.maps) {\n      initBelPartners();\n    } else {\n      setTimeout(checkDependencies, 100);\n    }\n  }\n\n  document.addEventListener('DOMContentLoaded', checkDependencies);\n<\/script>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":9,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"yamabiko-partners.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-6666","page","type-page","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>H\u00e4ndlersuche - Belrobotics<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"H\u00e4ndlersuche - Belrobotics\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/\" \/>\n<meta property=\"og:site_name\" content=\"Belrobotics\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/belrobotics\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-09T11:34:44+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data1\" content=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/\",\"url\":\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/\",\"name\":\"H\u00e4ndlersuche - Belrobotics\",\"isPartOf\":{\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#website\"},\"datePublished\":\"2019-06-03T09:25:20+00:00\",\"dateModified\":\"2024-10-09T11:34:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/#breadcrumb\"},\"inLanguage\":\"de-CH\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.belrobotics.com\/de-ch\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"H\u00e4ndlersuche\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#website\",\"url\":\"https:\/\/www.belrobotics.com\/de-ch\/\",\"name\":\"Belrobotics\",\"description\":\"The grass masters\",\"publisher\":{\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.belrobotics.com\/de-ch\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de-CH\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#organization\",\"name\":\"Belrobotics\",\"url\":\"https:\/\/www.belrobotics.com\/de-ch\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-CH\",\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.belrobotics.com\/wp-content\/uploads\/2019\/01\/logo-belrobotics.svg\",\"contentUrl\":\"https:\/\/www.belrobotics.com\/wp-content\/uploads\/2019\/01\/logo-belrobotics.svg\",\"width\":100,\"height\":16,\"caption\":\"Belrobotics\"},\"image\":{\"@id\":\"https:\/\/www.belrobotics.com\/de-ch\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/belrobotics\",\"https:\/\/www.youtube.com\/channel\/UCYgWBPRzEdXmUqLRL0JbUIw\",\"https:\/\/www.instagram.com\/belrobotics_europe\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"H\u00e4ndlersuche - Belrobotics","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/","og_locale":"de_DE","og_type":"article","og_title":"H\u00e4ndlersuche - Belrobotics","og_url":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/","og_site_name":"Belrobotics","article_publisher":"https:\/\/www.facebook.com\/belrobotics","article_modified_time":"2024-10-09T11:34:44+00:00","twitter_card":"summary_large_image","twitter_misc":{"Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/","url":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/","name":"H\u00e4ndlersuche - Belrobotics","isPartOf":{"@id":"https:\/\/www.belrobotics.com\/de-ch\/#website"},"datePublished":"2019-06-03T09:25:20+00:00","dateModified":"2024-10-09T11:34:44+00:00","breadcrumb":{"@id":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/#breadcrumb"},"inLanguage":"de-CH","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.belrobotics.com\/de-ch\/handlersuche\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.belrobotics.com\/de-ch\/"},{"@type":"ListItem","position":2,"name":"H\u00e4ndlersuche"}]},{"@type":"WebSite","@id":"https:\/\/www.belrobotics.com\/de-ch\/#website","url":"https:\/\/www.belrobotics.com\/de-ch\/","name":"Belrobotics","description":"The grass masters","publisher":{"@id":"https:\/\/www.belrobotics.com\/de-ch\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.belrobotics.com\/de-ch\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de-CH"},{"@type":"Organization","@id":"https:\/\/www.belrobotics.com\/de-ch\/#organization","name":"Belrobotics","url":"https:\/\/www.belrobotics.com\/de-ch\/","logo":{"@type":"ImageObject","inLanguage":"de-CH","@id":"https:\/\/www.belrobotics.com\/de-ch\/#\/schema\/logo\/image\/","url":"https:\/\/www.belrobotics.com\/wp-content\/uploads\/2019\/01\/logo-belrobotics.svg","contentUrl":"https:\/\/www.belrobotics.com\/wp-content\/uploads\/2019\/01\/logo-belrobotics.svg","width":100,"height":16,"caption":"Belrobotics"},"image":{"@id":"https:\/\/www.belrobotics.com\/de-ch\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/belrobotics","https:\/\/www.youtube.com\/channel\/UCYgWBPRzEdXmUqLRL0JbUIw","https:\/\/www.instagram.com\/belrobotics_europe\/"]}]}},"_links":{"self":[{"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/pages\/6666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/comments?post=6666"}],"version-history":[{"count":1,"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/pages\/6666\/revisions"}],"predecessor-version":[{"id":40216,"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/pages\/6666\/revisions\/40216"}],"wp:attachment":[{"href":"https:\/\/www.belrobotics.com\/de-ch\/wp-json\/wp\/v2\/media?parent=6666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}