Geolocation API quick reference

The Geolocation API is a web service that accepts an HTTPS POST request with the cell tower and Wi-Fi access point data a mobile client can detect. It returns latitude/longitude coordinates and an accuracy radius, and can fall back to IP-based geolocation.

Geolocation API: key facts

  • Product: Geolocation API
  • Category: Places
  • Platform: Web service (REST)
  • Runs on: Server (backend code)
  • Launch stage: GA
  • Lifecycle: Active
  • Overview: Geolocation API overview

Geolocation API: when to use it

Use Geolocation API when:

  • You need to locate a mobile device that has no built-in geolocation or GPS, using the cell tower and Wi-Fi access point data it can detect.
  • You need latitude/longitude coordinates plus an accuracy radius (in meters) from a server-side HTTPS POST request.
  • You need an approximate device location from the request IP address when Wi-Fi and cell data are missing or insufficient.

Don't use Geolocation API when:

  • You need the position of a user in a browser that supports HTML5 geolocation. Use Maps JavaScript API instead.
  • You need coordinates for an address or Place ID, or an address for given coordinates. Use Geocoding API instead.
  • You need the location of a mobile device with built-in location services (LocationManager or Fused Location Provider API on Android, Core Location on iOS).

Geolocation API: setup

Geolocation API: common mistakes

  • Problem: considerIp defaults to true, so when Wi-Fi and cell signals can't be geolocated the API silently falls back to IP geolocation and returns a very large accuracy radius. Fix: Set considerIp to false; a 404 then confirms that the wifiAccessPoints and cellTowers couldn't be geolocated. See /maps/documentation/geolocation/requests-geolocation-errors.
  • Problem: wifiAccessPoints needs two or more distinct stationary access points, and only universally-administered MAC addresses can be located. A broadcast MAC (FF:FF:FF:FF:FF:FF) in the list makes the whole request fail with 400 invalidRequest ("Invalid \"macAddress\" field."), and too few usable access points returns 404 notFound. Fix: Filter out broadcast (FF:FF:FF:FF:FF:FF) and IANA-reserved (00:00:5E) MACs and make sure that at least two usable access points remain. See /maps/documentation/geolocation/requests-geolocation.
  • Problem: For WCDMA and LTE, sending only the 16-bit or 8-bit Cell ID gives incorrect or zero results. Out-of-range values can be truncated or return NOT_FOUND with no indicator in the response. Fix: Compute the full cellId (WCDMA: rnc_id << 16 | cid; LTE: enb_id << 8 | cid) within the range 0 to 268435455. See /maps/documentation/geolocation/requests-geolocation.
  • Problem: Wi-Fi signalStrength values greater than -10 dBm (for example, a missing minus sign) cause the API to return NOT FOUND. Fix: Send signalStrength as a negative dBm value, including the minus sign. See /maps/documentation/geolocation/requests-geolocation.

What you can do with Geolocation API

See the guides linked below for each task, or compare across products in the Capabilities Explorer.