PageSourceSearch

https://www.orient-latin.com/assets/lib/geocode_country-54b48949cc…e6e12b0b63e593c0cf63e53ccebfddabb5011c86.js

js orient-latin.com collected 2026-10-02 11:47:14 UTC 874 bytes, 16 lines download raw bytes

1// Reverse-geocoding du pays d'un point (Geocoder Google, API Geocoding
2// activée sur la clé). Renvoie l'id de notre table countries d'après le code
3// ISO alpha-2 (short_name) et la table iso → id fournie ; null si le point est
4// hors liste (clic hors zone) ou la réponse sans pays. Rejette si le service
5// est indisponible : à l'appelant de décider (avertir, ou ignorer).
6let geocoder = null
7
8export function countryIdAt(lat, lng, isoToId) {
9  if (Object.keys(isoToId).length === 0) return Promise.resolve(null)
10  geocoder ??= new google.maps.Geocoder()
11
12  return geocoder.geocode({ location: { lat: parseFloat(lat), lng: parseFloat(lng) } }).then(({ results }) => {
13    const component = results.flatMap((r) => r.address_components).find((c) => c.types.includes("country"))
14    return (component && isoToId[component.short_name.toUpperCase()]) || null
15  })
16};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.