Skip to content

[geo-tools] GoogleAddressProvider now handles more API variants for location requests#1719

Open
johannes-goltz wants to merge 2 commits into
masterfrom
JohannesG/-geo-tools]-GoogleAddressProvider-does-not-resolve-location-request-correctly
Open

[geo-tools] GoogleAddressProvider now handles more API variants for location requests#1719
johannes-goltz wants to merge 2 commits into
masterfrom
JohannesG/-geo-tools]-GoogleAddressProvider-does-not-resolve-location-request-correctly

Conversation

@johannes-goltz

@johannes-goltz johannes-goltz commented Jun 15, 2026

Copy link
Copy Markdown

Issue
The GoogleAddressProvider does not always resolve a given place ID to coordinates correctly. It seems the API
supports different variants of query responses but only one variant (legacy ???) is currently accpted.

see screen shoot from my debug session:
image

Solution
GoogleAddressProvider.ts: broadened location extraction to accept alternative response shapes (top-level location, nested result.geometry.location.lat/lng, and other geometry variants). Kept existing behavior while adding fallbacks and validation.

@johannes-goltz johannes-goltz requested review from a team and mdastous-bentley as code owners June 15, 2026 08:54
@CLAassistant

CLAassistant commented Jun 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jason-crow

jason-crow commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The fix looks correct, but the inline comment could be more descriptive for future maintainers. Consider mapping each fallback arm to the specific API that produces that response shape:

// Google Address Validation API response shape: { location: { latitude, longitude } }
// @see https://developers.google.com/maps/documentation/address-validation/reference/rest/v1/TopLevel/validateAddress#Location
const lat = json?.location?.latitude
  // Google Geocoding API response shape: { result: { geometry: { location: { lat, lng } } } }
  // @see https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Results
  ?? json?.result?.geometry?.location?.lat
  // Legacy/wrapper format: { location: { geometry: { latitude, longitude } } }
  ?? json?.location?.geometry?.latitude;

const long = json?.location?.longitude
  ?? json?.result?.geometry?.location?.lng
  ?? json?.location?.geometry?.longitude;

This makes it clear which Google API produces each shape, so anyone encountering a new variant in the future knows exactly where to add the next fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants