What could be causing my Google Places nearby search to display atmosphere and contact information even when all fields are properly specified?

I created a fun game for the kids in my Scout troop to play while we're stuck at home during lockdown (www.riddlesdenscouts.org.uk/monsters).

I'm noticing charges on my bill for contact and atmosphere data from my local search, even though I only requested the geometry.location field. Any advice on how to fix this issue? Thank you!

  const request = {
    location: {lat: lat, lng: lon},
    radius: 1500,
    fields: ["geometry.location"],
    type:"point_of_interest",
  };
  service = new google.maps.places.PlacesService(map); 
  service.nearbySearch(request, (results, status) => {

Answer №1

If you want to narrow down the results from Nearby Search or Text Search to specific fields only, unfortunately there is no direct way to do that. However, to prevent unnecessary data retrieval and costs, you can utilize the findPlaceFromQuery method instead. You will need to provide an input query string in this case. By using a wildcard character in the query, you can retrieve a list of nearby points of interest.

const request = {
    locationBias: {
        center: {
            lat: lat,
            lng: lon
        },
        radius: 1500
    },
    query: "*",
    fields: ["geometry.location"],
};

service = new google.maps.places.PlacesService(map);
service.findPlaceFromQuery(request, (results, status) => {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
        for (var i = 0; i < results.length; i++) {
            //console.log(results[i]);
        }
    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways of converting a negative lookbehind into an ES5-friendly expression

In my code, I have a RegExp that works perfectly, but it only functions with ES2018 due to its use of negative lookbehinds. The problem is that a library is using this RegExp function, so modifying how it's used is not an option. I attempted to add n ...

Put dashes in the middle of each MongoDB post title

In my express app, users can create and view posts. Currently, I search for posts by their title. However, I am encountering an issue when the post title contains spaces. The search function works perfectly for titles without spaces, but it gives an error ...

Move files into the designated folder and bundle them together before publishing

Is there a way to transfer the files listed in package.json (under the File field) to a specific folder in order to bundle them together with npm publish? Here is the structure of my repository: . ├── package.json └── folder0 ├── fil ...

Python Mechanize file uploading capabilities

Hey there! I've been experimenting with mechanize and Python to upload a file to a website. I've had some success so far, but now I'm facing a challenge at the upload page. I understand that mechanize doesn't support JavaScript, but I&a ...

Building a jQuery DataTable with SQL Server and JSON Integration

I am having trouble figuring out what I am doing incorrectly. Could it be that the format I am using for executing an ajax call and returning JSON is not correct? My aim is to use JSON data to populate a DataTable. Although I have previously done somethin ...

Autocomplete failing to provide a valid response, returning a null value instead

Utilizing an Autocomplete feature for employee search, users can input a name and select from the list of results. However, the current onChange function logs the index value instead of the selected employee's name. Is there a way to pass the employee ...

Tips for maintaining the dropdown selection when new rows or columns are added to a table

I have a task requirement where I must generate a dynamic table using jQuery. I've successfully implemented adding dynamic columns or rows to the table. Feel free to check out the fiddle code here. HTML: <div id='input_div' name='i ...

Tips on coding javascript within an MVC4 C# environment

I am currently working with MVC 4 and facing an issue where I have the same action name for multiple views. This makes it difficult to write JavaScript code in all pages individually. Can I simply write the JavaScript in the C# action result instead? I at ...

Cannot save PDF files to a server using jsPDF

I'm new to this community and still learning javascript & php. I am having trouble saving my PDFs with jsPDF to the local storage on the server (automatically generated). It used to work in the past, but now when I add Canvas (javascript) to my HTML, ...

Is it crucial to invoke $ionicPlatform ready each time?

After noticing that $ionicPlatform.ready function is automatically executed in the app.js file generated by Ionic (within module.run), I pondered: Do I need to manually trigger $ionicPlatform.ready in controllers utilizing Cordova plugins which rely on on ...

In the iOS app when the Ionic HTML5 select keypad is opened, a bug causes the view to scroll upwards and create empty space after tapping the tab

I am currently working with Ionic v1 and AngularJS, utilizing ion tabs: <ion-tabs class="tabs-icon-top tabs-color-active-positive"> <!-- Home Tab --> <ion-tab icon-off="ion-home" icon-on="ion-home" href="#/tab/home"> <ion-nav ...

Converting HTML to PDF using JavaScript

My goal is to create an HTML page and then print and download it locally as a PDF. However, when I try to generate the PDF, it cuts off the last 3 to 4 lines of the page. I want to create multiple PDF pages in A4 size with the same styling as the HTML pa ...

Identify a request in NodeJS without relying on express or accessing the request object independently of an express middleware

I am struggling with accessing the request object outside of an express middleware in NodeJS. In my code snippet below, I need to read the request object from a file called mongoose_models.js, where I don't have access to the express middleware argume ...

Sort through the data that is already populated and proceed to paginate within Mongodb

Hey there, I'm currently working on populating some data and then implementing pagination for that data. Take a look at this example: Schema A (Users) { name: 'Demo', postId: 'someObjectId', } Schema B (Posts) { id: 's ...

Fade out the jQuery message after a brief 2-second pause

In my Rails application, I encountered an issue with a flash message that appears after successfully completing an AJAX action. The message displays "Patient Added" but does not include a way to close it without refreshing the page. To address this, I atte ...

error fetching data: unable to access due to client blocking

Despite including all possible information in my request, I am still encountering the same error. How can I identify the root cause of this issue? I have already disabled my AdBlocker extension. await fetch('http://127.0.0.1:8080/hxo.json?dummy=2s21&a ...

What is the best way to apply ng-style to a single element that was generated using $index within an ng-repeat loop

I am dealing with 2 directives: wa-hotspots and wa-tooltips. When the ng-mouseover event occurs on wa-hotspots, it takes the $index of wa-hotspot and adjusts the visibility and position of wa-tooltip using ng-class:on and ng-style="tooltipCoords" by matchi ...

KendoValidator seems to be demanding fields that do not have an actual requirement

I have a field in my form that is optional, but when I try to save the data, I encounter an issue with the validation message from Kendo. The validation should only check if it is a valid zipcode and allow it to be left blank. Additionally, the error messa ...

Sort through a collection of arrays that each contain objects

Having a challenge filtering a multidimensional array with objects within the inner arrays. Despite following examples found here, I'm still unable to successfully filter my array as desired. let arr = [ { name: 'brent', age: 123 } ]; Alth ...

Using Pocketbase OAuth in SvelteKit is not currently supported

I've experimented with various strategies, but I still couldn't make it work. Here's the recommendation from Pocketbase (): loginWithGoogle: async ({ locals }: { locals: App.Locals }) => { await locals.pb.collection('users' ...