I am using google’s Places API to retrieve a list of nearby places and display them in a list. It works fine in the simulator and does not work in the device (HTC Thunderbolt). It is like the listener never fires and the app will eventualy crash without displaying data.
...
--listener for Places API request
local function networkListener( event )
if ( event.isError ) then
-- myText.text = "Network error!"
else
-- myText.text = "See Corona Terminal for response"
--decode json table
local response = event.response
response = json.decode(response )
local status = response.status
print(status)
local rTest = display.newText(status, 0, 0, native.systemFontBold,22)
if status == "OK" then
local testValue = response.results[1].geometry.location.lat
local testValue2 = response.results[1].geometry.location.lng
Gdata= response.results
local i = 1
while Gdata[i] do
Gdata[i]["title"]=Gdata[i]["name"]
Gdata[i]["category"]=Gdata[i]["types"][1]
print ( "title: " .. Gdata[i]["title"] )
print ( "category: " .. Gdata[i]["category"] )
i=i+1
end--do
print ( "RESPONSE:LAT: " .. testValue )
print ( "RESPONSE:LNG: " .. testValue2 )
ReFresh()
end
end
end
--call to request a list of places
local function RequestPlaces(lLat,lLng)
local lRadius = 500 --update from user defined range
local lTypes = "bar|convenience\_store|liquor\_store"--update from user defined filter
local lSensor= "true"
local lKey = "Sorry\_not\_sharing\_my\_key"
network.request( "https://maps.googleapis.com/maps/api/place/search/json?location="..lLat..","..lLng.."&radius=".. lRadius.."&types="..lTypes.."&sensor="..lSensor.."&key="..lKey, "GET", networkListener )
print("requested")
return true
end
x = RequestPlaces(currentLatitude,currentLongitude)
print("DONE")
Any insight anyone can give me would be greatly appreciated. [import]uid: 40100 topic_id: 14177 reply_id: 314177[/import]
… would be nice if someone from Ansca would comment ( I would like a meaningfull comment not just a quick quip.) [import]uid: 40100 topic_id: 14177 reply_id: 55109[/import]