figured you’d ask to see my code, so here it is:
local composer = require "composer" local scene = composer.newScene() local widget = require "widget" -- name all local variables here -- defined local (scene) functions here local titleBar, navBar, myMap, addressBar local attempts = 0 local function maplocationHandler( event ) local currentLocation = myMap:getUserLocation() if ( currentLocation.errorCode or ( currentLocation.latitude == 0 and currentLocation.longitude == 0 ) ) then attempts = attempts + 1 if ( attempts \> 10 ) then native.showAlert( "No GPS Signal", "Can't sync with GPS.", { "Okay" } ) else timer.performWithDelay( 1000, locationHandler ) end else myMap:setCenter( currentLocation.latitude, currentLocation.longitude ) myMap:setRegion( currentLocation.latitude, currentLocation.longitude ) local options = { title="You are here", } myMap:addMarker( currentLocation.latitude, currentLocation.longitude, options ) end end local function mapSearchLocationHandler(event) if ( event.isError ) then print( "Map Error: " .. event.errorMessage ) else myMap:setCenter( event.latitude, event.longitude, false ) myMap:setRegion( event.latitude, event.longitude, 0.25, 0.25, false) local options = { title=event.text, } myMap:addMarker( event.latitude, event.longitude, options ) end end local function addressBarHandler( event ) if event.phase == "began" then elseif event.phase == "ended" or event.phase == "submitted" then myMap:requestLocation( event.target.text, mapSearchLocationHandlerLocationHandler ) native.setKeyboardFocus( nil ) elseif event.phase == "editing" then print( event.newCharacters ) print( event.oldText ) print( event.startPosition ) print( event.text ) end end function scene:create( event ) local sceneGroup = self.view --your code here; define display objects, sprites, physics bodies, etc - but don't play any sounds or animations yet. navBar = widget.newNavigationBar({ title = "Set Appointment Location", backgroundColor = { 0,0,0}, titleColor = {1, 1, 1}, }) sceneGroup:insert(navBar) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- any code placed here will run when the scene is still "off-screen", but about to be displayed to the user. In many cases, this will be empty. elseif ( phase == "did" ) then -- any code placed here will run as soon as the scene is displayed on screen. This is where you would start any animations, start playing background audio, start timers, etc. addressBar = native.newTextField(display.contentCenterX, navBar.y + 90, display.contentCenterX \* 1.8, 30) addressBar:addEventListener("userInput", addressBarHandler) sceneGroup:insert(addressBar) myMap = native.newMapView(0, 0,display.contentWidth , display.contentHeight + 50) if myMap then myMap.mapType = "standard" myMap.x = display.contentCenterX myMap.y = addressBar.y + 20 maplocationHandler() else native.showAlert( "Simulator", "Maps are only avaiable on device.", { "Okay" } ) end end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- any code placed here will run when the scene is still on screen, but is about to go off screen. This is where you would stop timers, audio, and animations that you created in the show event. elseif ( phase == "did" ) then -- any code placed here will run as soon as the scene is no longer visible. In many cases, this will be empty. addressBar:removeSelf() addressBar = nil if myMap and myMap.removeSelf then myMap:removeSelf() myMap = nil end end end function scene:destroy( event ) local sceneGroup = self.view -- any code placed here will run as the scene is being removed. Remove display objects, set variables to nil, etc. end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene