Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

App That Uses Maps API
Started by yanko_l10 Apr 10 2016 03:50 PM

63 replies to this topic
business maps api uber find my friends
[TOPIC CONTROLS]
Page 3 of 3 1 2 3
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

This line: print("URL:", URL, "*****")

 

has to be outputting something unless there are runtime errors just before it. Can you post your build.settings?

 

Do you have something like this:   showRuntimeErrors = false,

in your config.lua or do you have something like:

 

Runtime:addEventListener( "unhandledError", myUnhandledErrorListener )

 

in your code anywhere?



[TOPIC: post.html]
#52

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

I agree, this has been giving me a headache all day. I really dont understand why its not outputting anything at all in the console, and i dont see any runtime erros before it.

 

build.settings:

settings =
{
	iphone =
	{
		plist=
		{
			UIBackgroundModes = {"remote-notification"},
			UIApplicationExitsOnSuspend = false,
			NSLocationWhenInUseUsageDescription = "We need location services in order to specify appointment locations!",
			UIPrerenderedIcon = true,
			UIStatusBarHidden = false, 
			NSAppTransportSecurity =
			{
				NSExceptionDomains =
				{
					NSAllowsArbitraryLoads = true,
				
					["coronalabs.com"] =
					{
						NSIncludesSubdomains = true,
						NSThirdPartyExceptionAllowsInsecureHTTPLoads = true
					},
					["youtube.com"] =
					{
						NSIncludesSubdomains = true,
						NSThirdPartyExceptionAllowsInsecureHTTPLoads = true
					},
					["google.com"] =
					{
						NSIncludesSubdomains = true,
						NSThirdPartyExceptionAllowsInsecureHTTPLoads = true
					},
				},
			},

		},
	},
	orientation =
	{
		default = "portrait",
		supported =
		{
			"portait", "portraitUpsideDown", 
		},
	},
	android =
	{
		usesPermissions =
		{
			-- Required by the MapView to fetch its contents from the Google Maps servers.
			"android.permission.INTERNET",

			-- Optional permission used to display current location via the GPS.
			"android.permission.ACCESS_FINE_LOCATION",

			-- Optional permission used to display current location via WiFi or cellular service.
			"android.permission.ACCESS_COARSE_LOCATION",
			"com.google.android.c2dm.permission.RECEIVE",
		},
		usesFeatures =
		{
			-- If you set permissions "ACCESS_FINE_LOCATION" and "ACCESS_COARSE_LOCATION" above,
			-- then you may want to set up your app to not require location services as follows.
			-- Otherwise, devices that do not have location sevices (such as a GPS) will be unable
			-- to purchase this app in the app store.
			{ name = "android.hardware.location", required = false },
			{ name = "android.hardware.location.gps", required = false },
			{ name = "android.hardware.location.network", required = false },
		},
	},

	plugins =
	{ 
		["plugin.OneSignal"] =
		{
        publisherId = "com.onesignal",
		},
		["plugin.google.play.services"] =
		{
        publisherId = "com.coronalabs",
        supportedPlatforms = { android=true, ["android-kindle"]=true },
		},
	},  
}

and no to the rest of the questions!



[TOPIC: post.html]
#53

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

So apparently I had a function that i forgot to delete in my code that was interfering with the testEvent, I now got it to print the URL, but when i try to print myTable[1].barberid nothing is output. Heres the output from json.prettify:

 

I/Corona  (12244): URL: *****
I/Corona  (12244): {
I/Corona  (12244):   "bytesEstimated":-1,
I/Corona  (12244):   "bytesTransferred":163,
I/Corona  (12244):   "name":"networkRequest",
I/Corona  (12244):   "phase":"ended",
I/Corona  (12244):   "requestId":"<type 'userdata' is not supported by JSON.>",
I/Corona  (12244):   "response":"{\"1\":{\"barberid\":\"2\",\"distance\":\"0.05304842361994396\"},\"2\":{\"barberid\":\"5\",\"distance\":\"0.05304842361994396\"},\"3\":{\"barberid\":\"6\",\"distance\":\"0.05304842361994396\"}}",
I/Corona  (12244):   "responseHeaders":{
I/Corona  (12244):     "Connection":"Keep-Alive",
I/Corona  (12244):     "Content-Type":"text/html",
I/Corona  (12244):     "X-Android-Response-Source":"NETWORK 200",
I/Corona  (12244):     "Date":"Mon, 18 Jul 2016 18:10:06 GMT",
I/Corona  (12244):     "X-Android-Sent-Millis":"1468865405753",
I/Corona  (12244):     "X-Android-Received-Millis":"1468865405811",
I/Corona  (12244):     "X-Android-Selected-Transport":"http/1.1",
I/Corona  (12244):     "Keep-Alive":"timeout=5, max=100",
I/Corona  (12244):     "X-Powered-By":"PHP/5.5.9-1ubuntu4.14",
I/Corona  (12244):     "Vary":"Accept-Encoding",
I/Corona  (12244):     "HTTP-STATUS-LINE":"HTTP/1.1 200 OK",
I/Corona  (12244):     "Server":"Apache/2.4.7 (Ubuntu)"
I/Corona  (12244):   },
I/Corona  (12244):   "responseType":"text",
I/Corona  (12244):   "status":200,
I/Corona  (12244):   "url":"http://107.170.34.199/barber_search_script.php?currentLat=25.9901778&currentLng=-80.3572953",
I/Corona  (12244):   "isError":false
I/Corona  (12244): }
I/Corona  (12244): Success!
I/Corona  (12244): {"1":{"barberid":"2","distance":"0.05304842361994396"},"2":{"barberid":"5","distance":"0.05304842361994396"},"3":{"barberid":"6","distance":"0.05304842361994396"}}
 

last line is the output of print(event.response)



[TOPIC: post.html]
#54

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

Your data is now basically:

 

myTable[1].barberid = 2

myTable[1].distance = 0.05304

myTable[2].barberid = 5

myTable[2].distance = 0.05304

myTable[3].barberid = 6

myTable[3].distance = 0.05304



[TOPIC: post.html]
#55

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

That's what i thought too, but print(myTable[1].barberid) isnt outputting anything in the console.



[TOPIC: post.html]
#56

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

Try changing your PHP script from:

echo json_encode($barbers);

to

echo json_encode($barbers, JSON_NUMERIC_CHECK );

Your numeric array keys ($q) is being converted to a string and so are other number items. Try that and see if it behaves better.

 

Rob



[TOPIC: post.html]
#57

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

Tried that, still isn't printing anything to the console



[TOPIC: post.html]
#58

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

What is being printed to the console now?



[TOPIC: post.html]
#59

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

I/Corona  (21742): {
I/Corona  (21742):   "bytesEstimated":-1,
I/Corona  (21742):   "bytesTransferred":148,
I/Corona  (21742):   "name":"networkRequest",
I/Corona  (21742):   "phase":"ended",
I/Corona  (21742):   "requestId":"<type 'userdata' is not supported by JSON.>",
I/Corona  (21742):   "response":"{\"1\":{\"barberid\":2,\"distance\":0.0043117895569319},\"2\":{\"barberid\":5,\"distance\":0.0043117895569319},\"3\":{\"barberid\":6,\"distance\":0.0043117895569319}}",
I/Corona  (21742):   "responseHeaders":{
I/Corona  (21742):     "Connection":"Keep-Alive",
I/Corona  (21742):     "Content-Type":"text/html",
I/Corona  (21742):     "X-Android-Response-Source":"NETWORK 200",
I/Corona  (21742):     "Date":"Tue, 19 Jul 2016 19:27:51 GMT",
I/Corona  (21742):     "X-Android-Sent-Millis":"1468956470146",
I/Corona  (21742):     "X-Android-Received-Millis":"1468956470219",
I/Corona  (21742):     "X-Android-Selected-Transport":"http/1.1",
I/Corona  (21742):     "Keep-Alive":"timeout=5, max=100",
I/Corona  (21742):     "X-Powered-By":"PHP/5.5.9-1ubuntu4.14",
I/Corona  (21742):     "Vary":"Accept-Encoding",
I/Corona  (21742):     "HTTP-STATUS-LINE":"HTTP/1.1 200 OK",
I/Corona  (21742):     "Server":"Apache/2.4.7 (Ubuntu)"
I/Corona  (21742):   },
I/Corona  (21742):   "responseType":"text",
I/Corona  (21742):   "status":200,
I/Corona  (21742):   "url":"http://107.170.34.199/barber_search_script.php?currentLat=25.9907928&currentLng=-80.3568651",
I/Corona  (21742):   "isError":false
I/Corona  (21742): }
I/Corona  (21742): Success!
I/Corona  (21742): {"1":{"barberid":2,"distance":0.0043117895569319},"2":{"barberid":5,"distance":0.0043117895569319},"3":{"barberid":6,"distance":0.0043117895569319}}

 

networkListener:

local function networkListener( event )
	print( json.prettify( event ) )
    if ( event.isError ) then
        print( "Network error: ", event.response )
    else
        print ( "Success!" )
		myTable = json.decode(event.response)
		print(event.response)
		print(myTable[1].barberid)
	end
end

I even tried changing the php script to fetch_row instead of fetch_assoc, still nothing. (right now its back to fetc_assoc)



[TOPIC: post.html]
#60

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

The keys are strings, not numbers which is weird. But it id convert the id and distance to numbers correctly.



[TOPIC: post.html]
#61

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

Yeah youre right. Funny thing is i thought about that before and tried changing the way the loop stored the rows in the array in php but it didnt work as i expected it to. I now did print(myTable["1"].barberid and it worked. I don't understand why the index is stored as a string when i defined the counter to be 1, weird.



[TOPIC: post.html]
#62

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

Do you think it has anything to do with the way json encodes the table? I tried converting the counter to an int (even though there shouldn't be the need to since its supposedly already an int), and still couldnt change the key to be a number. I also tried making a variable called index to use when looping through the table, and it didnt work how i expected it to.

 

Would be something like this (no loop yet):

local index = 1
tostring(index)
print(myTable[index].barberid)


[TOPIC: post.html]
#63

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,913 posts
  • Enterprise

More like:

local index = 1
print(myTable[tostring(index)].barberid)


[TOPIC: post.html]
#64

yanko_l10

[GLOBAL: userInfoPane.html]
yanko_l10
  • Enthusiast

  • 81 posts
  • Corona SDK

Nice, your way worked. Thanks for all the help Rob!




[topic_controls]
Page 3 of 3 1 2 3
 
[/topic_controls]