AddThisFeature

Mapbox Geocoding

Convert typed locations into coordinates and structured addresses the app can use.

involved Integrations

What it adds

Forward and reverse geocoding with confirmed matches, controlled result bias, and coordinate precision rules.

What your agent is told to do

5
  1. 1

    Separate the two directions explicitly: text to coordinates for entry and search, coordinates to address for a dropped pin or a device location. They take different inputs, carry different confidence, and fail differently.

  2. 2

    Present ambiguous matches as a list the user confirms. Silently taking the first result is how a record ends up in the wrong country with nobody noticing for months.

  3. 3

    Bias results toward a location only when the app genuinely knows one, such as a workspace address or the map viewport the user is already looking at.

  4. 4

    Keep the request credential off the public page, or scope it to one capability and origin. Store returned coordinates at a precision that suits the use, and record who is permitted to see them.

  5. 5

    Google Places Address Lookup covers address autocomplete for form entry. Where both exist, use one provider per field and keep their stored identifiers separate, because identifiers from the two providers are not interchangeable.

Edge cases it handles

8
  • Bias applied without real context distorts results — a user searching for a place in another country gets local noise instead of the answer. Guessed bias is worse than none.
  • Two plausible matches must be offered as a choice. Automatic selection is acceptable only when the match is unambiguous and the app can explain why.
  • The provider's terms govern attribution and how long results may be cached. Show the required attribution where results appear and respect the caching window rather than building a permanent local copy.
  • Reverse lookup of a coordinate in open country may return only a broad region or nothing at all. Treat an empty result as a valid outcome, not an error.
  • Coordinates describing a person are personal data. Round to the precision the feature actually needs, state who can see the exact value, and do not store street-level precision for a feature that only needs a city.
  • Rate limits apply per credential. Debounce interactive lookups, run bulk work through the app's existing background-job system, and back off on throttling instead of hammering.
  • A geocode failure must not block a save. Keep the typed text, mark the record as not yet geocoded, and retry later.
  • Coordinates that arrive reversed or outside valid bounds must be rejected before they reach a map or a distance calculation.

Definition of done

9
  • Forward and reverse lookup are separate paths with their own error handling.
  • Ambiguous matches are confirmed by the user rather than auto-selected.
  • Bias is applied only from known context and never from a guessed source.
  • Required attribution is shown and caching stays within the provider's terms.
  • Stored coordinate precision matches the feature's need and is covered by an access rule.
  • A failed or empty geocode leaves the record saveable with the typed text intact.
  • Bulk geocoding runs as background jobs that back off when throttled.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.