Tiger_Location

@api

Tiger_Location — the Location Service facade.

One entry point for every location lookup. Throw it a partial address (suggest/geocode), a lat/lng (reverse), or an IP (ip); it routes to the configured, capable adapter and returns the same Tiger_Location_Place payload regardless of provider. Providers are chosen by config, per operation group:

tiger.location.address.provider = "nominatim" ; suggest / geocode / reverse tiger.location.ip.provider = "ipapi" ; ip tiger.location.adapters..* ; that adapter's own config

Graceful by design: an unset provider, a missing/incapable adapter, or a provider error yields empty results (never a fatal), so a form's autocomplete just quietly does nothing when unconfigured. Register more adapters with Tiger_Location::register().

Methods

register()

register(string $name, string $class): void

Register (or replace) a provider name -> adapter class.

  • $name string — the provider name (case-insensitive)
  • $class string — the adapter class to instantiate for it

suggest()

suggest(string $query, array $opts = []): array

Suggest address matches for a partial query via the configured address provider.

  • $query string — the partial address text
  • $opts array — provider options (e.g. country bias)

Returns array — the suggestions, or [] when unconfigured or on error

geocode()

geocode(string $query, array $opts = []): array

Geocode a query to structured place(s) via the configured address provider.

  • $query string — the address text to geocode
  • $opts array — provider options (e.g. country bias)

Returns array — the matches, or [] when unconfigured or on error

reverse()

reverse(float $lat, float $lng, array $opts = []): ?Tiger_Location_Place

Reverse-geocode a coordinate to the nearest place via the configured address provider.

  • $lat float — the latitude
  • $lng float — the longitude
  • $opts array — provider options

Returns ?Tiger_Location_Place — the place, or null when unconfigured or on error

ip()

ip(string $ip, array $opts = []): ?Tiger_Location_Place

Geolocate an IP address via the configured IP provider.

  • $ip string — the IP address to look up
  • $opts array — provider options

Returns ?Tiger_Location_Place — the place, or null on an invalid IP, unconfigured, or error