تخطَّ إلى المحتوى
توثيق المطورين

التعامل مع العناوين العربية

Search, forward geocode and reverse geocode Egyptian addresses, and know when a result is approximate.

التعامل مع العناوين العربية

Search, forward geocode and reverse geocode Egyptian addresses, and know when a result is approximate.

Egyptian addresses are frequently informal: a landmark, a mosque, a shop, then a street. Bardiya's index is built for that shape, and it folds Arabic orthographic variation itself, which means your client should send text as the user typed it.

Do not pre-normalise

  • Send raw keystrokes to autocomplete. Diacritics, alef variants (أ إ آ ا), ta marbuta and ya/alef maqsura are folded server-side.
  • Do not transliterate Arabic into Latin script. Both scripts index the same place.
  • Do not strip the landmark. "بجوار مسجد النور" is a useful query; "شارع النصر" alone often is not.
ts
const suggestions = await fetch(
  `https://api.bardiyamap.com/v1/places/autocomplete?${new URLSearchParams({
    q: "مسجد الن",
    latitude: "30.0444",
    longitude: "31.2357",
    limit: "5",
    language: "ar",
  })}`,
  { headers: { "X-API-Key": key } },
).then((response) => response.json());

Forward and reverse are different questions

QuestionOperationUse when
Where is this text?GET /v1/geocodeThe user typed an address and you need coordinates
What is at this point?GET /v1/geocode/reverseA pin was dropped, or a device reported a position
python
forward = geocode("٥ شارع النصر، مدينة نصر، القاهرة", latitude=30.0397, longitude=31.2035, language="ar")
# forward.results[0].coordinate is where the text was matched

reverse = reverse_geocode(30.0397, 31.2035, nearby_limit=5, language="ar")
# reverse.street_match is the nearest known street; components carries the parts

Uncertainty is information, not noise

A reverse geocode answers with the nearest known street, which may be tens of metres away, and a forward geocode may match a street rather than a building. Both are useful and neither is exact. Surface the precision to the user instead of presenting a precise-looking pin.

  • Show the matched name, not only the pin, so the user can see it is the right street.
  • When the match is a street rather than a house number, ask for the building detail instead of guessing.
  • Keep the user's raw text alongside the resolved coordinates: a later correction needs the original input.
  • Prefer a place_id from search over re-geocoding free text. Place ids are stable; free text is not.