I am trying to get mapview working to display locations out of a table, stage one was to get it to show the current location. this worked fine after finding some code to make it wait until the map is ready, however now I am trying to get the location from an address string.
[lua]local function setmapcenter()
if myMap then
local current_location = myMap.getUserLocation()
current_address = myMap:nearestAddress(current_location.latitude, current_location.longitude, mapAddressHandler)
local loc = myMap:requestLocation(“131 Leichhardt street”, mapLocationHandler)
myMap:setRegion( loc.latitude, loc.longitude, 0.01, 0.01, true )
end
end
local function mapLocationHandler( event )
if event.isError then
– Location name not found.
native.showAlert( “Error”, event.errorMessage, { “OK” } )
else
– Move map so this location is at the center
– (The final parameter toggles map animation, which may not be visible if moving a large distance)
myMap:setCenter( event.latitude, event.longitude, true )
– Add a pin to the map at the new location
markerTitle = "Location " … locationNumber
locationNumber = locationNumber + 1
myMap:addMarker( event.latitude, event.longitude, { title=markerTitle, subtitle=inputField.text } )
native.showAlert( “location”, “It supposedly worked”, { “OK” } )
end
end[/lua]
When it runs myMap:requestLocation on the actual device I get this runtime error :
Bed self argument to requestLocation (the third argument of requestLocation should be a listener.)
The problem is, the API docs says :
object:requestLocation( location, resultHandler )
String. The address, intersection, or landmark.
Do I need to add an event listener line like
myMap:addEventListener( “mapLocationHandler”, mapLocationHandler)
becuase I am using storyboard? (I actually tried the above and it did not help)