Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GooglePlaceData type is missing terms field #960

Open
2 of 4 tasks
mehran75 opened this issue Dec 31, 2024 · 0 comments
Open
2 of 4 tasks

GooglePlaceData type is missing terms field #960

mehran75 opened this issue Dec 31, 2024 · 0 comments
Labels

Comments

@mehran75
Copy link

mehran75 commented Dec 31, 2024

Describe the bug

Seems like the type GooglePlaceData is missing the field terms. the terms is instead under StructuredFormatting which is not matched with the returned results.

Reproduction

types from react-native-google-places-autocomplete

interface StructuredFormatting {
  main_text: string;
  main_text_matched_substrings: Object[][];
  secondary_text: string;
  secondary_text_matched_substrings: Object[][];
  terms: Term[];
  types: PlaceType[];
}

interface GooglePlaceData {
  description: string;
  id: string;
  matched_substrings: MatchedSubString[];
  place_id: string;
  reference: string;
  structured_formatting: StructuredFormatting;
}

------------- my code -----------

function onConfirmAddress(data: GooglePlaceData, details: GooglePlaceDetail | null = null) {
        console.log(data.terms)
        console.log('-------------------------')
        console.log(data);
        console.log("-------------------------")
        // console.log(details);
    }
 (NOBRIDGE) LOG  [{"offset": 0, "value": "5th Avenue"}, {"offset": 12, "value": "Manhattan"}, {"offset": 23, "value": "New York"}, {"offset": 33, "value": "NY"}, {"offset": 37, "value": "USA"}]
 (NOBRIDGE) LOG  -------------------------
 (NOBRIDGE) LOG  {"description": "5th Avenue, Manhattan, New York, NY, USA", "matched_substrings": [{"length": 1, "offset": 0}, {"length": 9, "offset": 12}], "place_id": "Eig1dGggQXZlbnVlLCBNYW5oYXR0YW4sIE5ldyBZb3JrLCBOWSwgVVNBIi4qLAoUChIJ9Uc4naJYwokRSndBAbr7TVYSFAoSCWHmbgSPWMKJEYzA7PyBMgsK", "reference": "Eig1dGggQXZlbnVlLCBNYW5oYXR0YW4sIE5ldyBZb3JrLCBOWSwgVVNBIi4qLAoUChIJ9Uc4naJYwokRSndBAbr7TVYSFAoSCWHmbgSPWMKJEYzA7PyBMgsK", "structured_formatting": {"main_text": "5th Avenue", "main_text_matched_substrings": [[Object]], "secondary_text": "Manhattan, New York, NY, USA", "secondary_text_matched_substrings": [[Object]]}, "terms": [{"offset": 0, "value": "5th Avenue"}, {"offset": 12, "value": "Manhattan"}, {"offset": 23, "value": "New York"}, {"offset": 33, "value": "NY"}, {"offset": 37, "value": "USA"}], "types": ["route", "geocode"]}
 (NOBRIDGE) LOG  -------------------------

Additional context

  • Library Version: 2.5.7

  • React Native Version: 0.76.5

  • iOS

  • Android

  • Web

If you are using expo please indicate here:

  • I am using expo

More info

Google Places API doc: https://developers.google.com/maps/documentation/places/web-service/autocomplete#PlaceAutocompletePrediction

image
image

@mehran75 mehran75 added the bug label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant