I've completed lesson 4, but the Show Address function isn't working. It doesn't bring up any code error, there's just no response at all. Locate Me and Directions work. I've combed through the script about 10 times, compared it to the video and the pdf, and can't see my mistake, which probably means it's extremely obvious to someone else.
Can anyone spot the error?
Here's the Search button script
Code: Select all
on touchEnd pId
mobGUIUntouch the long id of me
if the uOptionType of group "mapType" is "Show Address" then
showAddress the uText of group "searchAddress"
else if the uOptionText of group "mapType" is "Directions" then
showDirections the uText of group "searchAddress"
end if
end touchEnd
Code: Select all
on openCard
if the environment is "mobile" then
mobileStartTrackingSensor "location"
end if
end openCard
on closeCard
if the environment is "mobile" then
mobileStopTrackingSensor "location"
end if
end closeCard
on showCurrentLocation
local tURL
put currentLocationURL() into tURL
displayURL tURL
end showCurrentLocation
function currentLocationURL
local tLatitude, tLongitude, tURL
put item 1 of getCurrentLocation() into tLatitude
put item 2 of getCurrentLocation() into tLongitude
if tLatitude is empty then
put "55.95369" into tLatitude
end if
if tLongitude is empty then
put "-3.198784" into tLongitude
end if
put "http://maps.google.com/maps?q=" & tLatitude & comma & tLongitude into tURL
return tURL
end currentLocationURL
function getCurrentLocation
local tLocationArray
if the environment is "mobile" then
if mobileSensorAvailable("location") then
put mobileCurrentLocation() into tLocationArray
return tLocationArray["latitude"] & comma & tLocationArray["longitude"]
else
return empty
end if
else
return empty
end if
end getCurrentLocation
on displayURL pURL
replace comma with "%2C" in pURL
replace space with "%20" in pURL
get urlEncode(pURL)
if the environment is "mobile" then
set the uURL of group "map" to pURL
else
launch url pURL
end if
end displayURL
on showAddress pAddress
local tURL
put addressURL(pAddress) into tURL
displayURL tURL
end showAddress
function addressURL pAddress
local tURL
replace comma with "%2C" in pAddress
replace space with "%20" in pAddress
get urlEncode(pAddress)
put "http://maps.google.com/maps?q=" & pAddress into tURL
return tURL
end addressURL
on showDirections pAddress
local tURL
put directionsURL(pAddress) into tURL
displayURL tURL
end showDirections
function directionsURL pAddress
local tLatitude, tLongitude, tURL
put item 1 of getCurrentLocation() into tLatitude
put item 2 of getCurrentLocation() into tLongitude
if tLatitude is empty then
put "55.95369" into tLatitude
end if
if tLongitude is empty then
put "-3.198784" into tLongitude
end if
replace comma with "%2C" in pAddress
replace space with "%20" in pAddress
get urlEncode(pAddress)
put "http://maps.google.com/maps?saddr=" & tLatitude & comma & tLongitude & "&daddr=" & pAddress into tURL
return tURL
end directionsURL