Inverse to most location querying efforts, I am actually trying to identify a business' name with Google APIs by either its address or Google placeid
. e.g., when I search for 1625 Wilshire Blvd, Los Angeles, CA 90017
on googlemaps.com, its results show me that "at this location" is "McDonald's".
However, when making the API call with the following URL, the name comes up as the street address, when what I want is to identify the business' name at that location ("McDonald's"):
https://maps.googleapis.com/maps/api/place/textsearch/json?query=1625%20Wilshire%20Blvd,%20Los%20Angeles,%20CA%2090017&sensor=false&key=<api_key>
EDIT: Using the exact call that @xomena recommended, I'm still having the same issue. I've run it both R and Python and the result I’m getting is the street address in place of the name with both ways.
R Code:
packages <- c("RJSONIO")
new_packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new_packages)) install.packages(new_packages)
library(RJSONIO)
fromJSON(URLencode(paste("https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=1625%20Wilshire%20Blvd%2C%20Los%20Angeles%2C%20CA%2090017&inputtype=textquery&fields=formatted_address,name,place_id&key=", api_key, sep = "")))
R Output:
$candidates
$candidates[[1]]
formatted_address
"1625 Wilshire Blvd, Los Angeles, CA 90017, USA"
name
"1625 Wilshire Blvd"
place_id
"ChIJ18AW_aPHwoARXRm-cgcRcDs"
$debug_log
$debug_log$line
list()
$status
[1] "OK"
Python Code:
import requests
requests.get("https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=1625%20Wilshire%20Blvd%2C%20Los%20Angeles%2C%20CA%2090017&inputtype=textquery&fields=formatted_address,name,place_id&key="+API_KEY).json()
Python Output:
{'candidates': [{'formatted_address': '1625 Wilshire Blvd, Los Angeles, CA 90017, USA',
'name': '1625 Wilshire Blvd',
'place_id': 'ChIJ18AW_aPHwoARXRm-cgcRcDs'}],
'debug_log': {'line': []},
'status': 'OK'}