Currently, I am utilizing the Google Maps Places Autocomplete Javascript API to enable users to choose a location by searching for the address or name of an establishment. Here is an example code snippet:
autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function () {
console.log(autocomplete.getPlace());
});
This code snippet retrieves the following data:
{
"address_components":[
{
"long_name":"1600",
"short_name":"1600",
"types":[
"street_number"
]
},
{
"long_name":"Amphitheatre Parkway",
"short_name":"Amphitheatre Pkwy",
"types":[
"route"
]
},
{
"long_name":"Mountain View",
"short_name":"Mountain View",
"types":[
"locality",
"political"
]
},
{
"long_name":"Santa Clara County",
"short_name":"Santa Clara County",
"types":[
"administrative_area_level_2",
"political"
]
},
{
"long_name":"California",
"short_name":"CA",
"types":[
"administrative_area_level_1",
"political"
]
},
{
"long_name":"United States",
"short_name":"US",
"types":[
"country",
"political"
]
},
{
"long_name":"94043",
"short_name":"94043",
"types":[
"postal_code"
]
}
],
"adr_address":"<span class=\"street-address\">1600 Amphitheatre Pkwy</span>, <span class=\"locality\">Mountain View</span>, <span class=\"region\">CA</span> <span class=\"postal-code\">94043</span>, <span class=\"country-name\">USA</span>",
"formatted_address":"1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"formatted_phone_number":"(650) 253-0000",
"geometry":{
"location":{
"lat":37.4219999,
"lng":-122.08405749999997
},
"viewport":{
"south":37.4206993697085,
"west":-122.0847981802915,
"north":37.4233973302915,
"east":-122.08210021970848
}
},
"icon":"https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id":"3a936e96ddcb18b4fa8a2974ebc8876c3108fef2",
"international_phone_number":"+1 650-253-0000",
"name":"Googleplex",
"place_id":"ChIJj61dQgK6j4AR4GeTYWZsKWw",
"rating":4.4,
"reference":"CmRRAAAACSrJEHCvJp1k1sNsnP1YvwaVcHxCPCdgt9vF-dLxsyUO-VoVoJ44QUHBeay_xRA29z7r9M_Pl-GCRFke9AbTjR7uOQg6ujPCc2gI3yaVlTVIBOAfxlamFaYbwzInWZDYEhA6V8crd3XJ8w-LHYNjzm2RGhSjYXAaGOf9ewF1emkXjxFJu-tO7g",
"url":"https://maps.google.com/?cid=7793879817120868320"
}
I understand that there is unnecessary data included. This extra data is proving costly for me, as "Places Details," "Atmosphere Data," and "Contact Data" incur charges per request.
In my billing console, there is a specific entry called "Autocomplete without Places Details - Per Session." This indicates that I have the option to make a request without all the superfluous details. How can I go about making such a request instead of one that includes all the establishment specifics?