Cannot add Marker in mapView

Hello,

Not sure if I’m doing something wrong. I added a button to show the lat/long and it works. So right after in the button event I tried to add a marker but it does not show. Am I doing something wrong?

For the code below I have been grabbing peices from examples in the documentation here.

local widget = require ( "widget" ) local myMap local myLat local myLong local myLocation local myOptions local myMap local locationtxt2 local onbtnEvent = function ( event ) local phase = event.phase if "ended" == phase then local locationTable2 = myMap:getUserLocation() locationtxt2 = display.newText("My1 location is: ", 100, 440, native.systemFont, 16) if locationTable2.errorCode then locationtxt2.text = locationtxt2.text .. locationTable2.errorMessage else locationtxt2.text = locationtxt2.text .. locationTable2.latitude .. ", " ..locationTable2.longitude local options = { title="Displayed Title", subtitle="subtitle text" } myMap:addMarker( locationTable2.latitude, locationTable2.longitude, options ) end end end myMap = native.newMapView( 5, 20, 315, 360 ) myMap.mapType = "standard" -- other mapType options are "satellite" or "hybrid" local btnPost = widget.newButton{ label = "Address", id = "btn002", left = 80, top = 450, width = 125, height = 40, fontSize = 11, cornerRadius = 8, onEvent = onbtnEvent } btnPost.x = 80 btnPost.y = 450 local function callMap() -- Fetch the user's current location -- Note: in XCode Simulator, the current location defaults to Apple headquarters in Cupertino, CA local currentLocation = myMap:getUserLocation() if currentLocation then -- Move map so that current location is at the center local currentLatitude = currentLocation.latitude local currentLongitude = currentLocation.longitude myMap:setCenter( currentLatitude, currentLongitude, true ) -- Look up nearest address to this location (this is returned as a "mapAddress" event, handled above) myMap:nearestAddress( currentLatitude, currentLongitude ) local locationText2 = "Latitude: " .. currentLatitude .. ", Longitude: " .. currentLongitude end end -- A function to handle the "mapAddress" event (also known as "reverse geocoding") -- local mapAddressHandler = function( event ) local locationTable3 = myMap:getUserLocation() if locationTable3.errorCode then -- else local options = { title="Displayed Title", subtitle="subtitle text" } --myMap:addMarker( locationTable3.latitude, locationTable3.longitude, options ) end end -- A listener for the address lookup result -- (This could also be a table listener on the map itself, in case you have more than one simultaneous map.) Runtime:addEventListener( "mapAddress", mapAddressHandler ) --timer.performWithDelay( 1000, callMap ) -- get current location after 1 second