brh55 / react-native-open-maps

🗺 A simple react-native library to perform cross-platform map actions (Google, Apple, or Yandex Maps)
MIT License
359 stars 47 forks source link

queryPlaceId parameter doesn't work #51

Open hasfoug opened 2 years ago

hasfoug commented 2 years ago

I am currently working on integrating this into my application. I am specifying latitude and longitude along with the queryPlaceId parameter, as a result, I am getting navigated to the coordinates, but the place is not being selected (I need to tap on it manually).

My code is:

    open({
      latitude: lat,
      longitude: lon,
      zoom: 30,
      provider: 'google',
      queryPlaceId: googlePlacesId,
    });

I've tried without latitude and longitude, but it just opens the map with my current location in this case. The only working way for me to have the place preselected was to only query by name (without specifying the coordinates), but this leads to an issue that some places are not unique by name and I might get several results.

Thanks in advance!

cnnrznn commented 11 months ago

Ultimately, it looks like this param isn't used in link creation: https://github.com/brh55/react-native-open-maps/blob/main/index.js#L200-L251.

I'm facing the same issue, and will spend some time investigating how easy this would be to PR

Edit: it is used, but still investigating why it doesn't work

cnnrznn commented 11 months ago

@hasfoug it turns out this is completely the correct behavior. From the docs:

query_place_id (optional): A place ID is a textual identifier that uniquely identifies a place. For the search action, you must specify a query, but you may also specify a query_place_id. If you specify both parameters, the query is only used if Google Maps cannot find the place ID. If you are trying to definitively link to a specific establishment, the place ID is the best guarantee that you will link to the right place. It is also recommended to submit a query_place_id when you query for a specific location using latitude/longitude coordinates.

So, if you want to search, you have to supply the query param, but it will only be used as a fallback in case place_id cannot be found.

For my app, I'll use the place_description returned from the Places - Autocomplete API as the query string

cnnrznn commented 11 months ago

This issue, per my comment above, can probably be closed