'How to Add Google Map Places "textSearch()" api in React Native

I have a tourist App, and i have made a tab i.e ATM onPress it will display List of ATM's in nearby defined Radius.

I have tried Different modules which available in NPM website, but didn't figured it out the use case for my specific result

The problem i have facing is when reading '''textSearch()''' documentation's is uses '''google.maps.places.PlacesService(map);''' from where this .object should i import

if any relevant sources welcome



Solution 1:[1]

const handleSearch = async () => {
  const url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?";
  const fulllocation = `location=${location.latitude},${location.longitude}`;
  const radius = `&radius=2000`;
  const type = `&keyword=ATM`;
  const key = "&key=xyz";
  const restaurantSearchUrl = url + fulllocation + radius + type + key;

  await fetch(restaurantSearchUrl)
    .then((response) => response.json())
    .then((result) => setPlaceData(result))
    .catch((e) => console.log(e));

I have used placeSearch to get result - but it needed to click few times to get the result, on first click it shows empty array then on second click it shows result with "status" : "ZERO_RESULTS" then after few clicks it shows the results. I have tried to use async/await to get result, but it gives empty array or ZERO_RESULTS. How can i fix thatenter image description here

Every array of object is a result after click

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Asgar Ali Khachay