Map Question?

I’m working on an app that will display a map and track my movement by placing a breadcrumb trail as a move, display distance, speed, time I have travelled etc etc.

Now, my first issue is that when the app starts it shows some place in china and I want it to center up on my position and track me as I move so I am always center of map. From what I have read, I should use this;

 myLocation = myMap:getUserLocation()  
 myLatitude = myLocation.latitude  
 myLongitude = myLocation.longitude  
 myMap:setCenter(myLatitude, myLongitude, true)  
 myMap.isLocationUpdating = true  

But it doesn’t work and it only show a blue screen, like it’s just ocean everywhere. What am I doing wrong?

[code]
– App is in landscapeLeft

– Statusbar
display.setStatusBar( display.HiddenStatusBar )

– Modules
local ui = require (“ui”)

– Global vars
screenWidth = display.contentWidth
screenHeight = display.contentHeight

– Forward references
local mapGroup

– labels
local altitude
local speed
local latitude
local longitude
local distance
local myTimer

– Buttons
local startButton
local stopButton
local optionsButton
local mapTypeButton_id1
local mapTypeButton_id2
local mapTypeButton_id3

– Map stuff
local myMap
local myLocation
local myLongitude
local myLatitude
– Display Objects
local sideBar

– Code below here
local startApp = function()
print("–> App Started")
showMap()
end

– Function to handle the map
showMap = function()
mapView = display.newGroup()

sideBar = display.newRect(0, 0, screenWidth*0.3, screenHeight)
sideBar:setReferencePoint(display.TopLeftReferencePoint)
sideBar:setFillColor ( 1, 222, 12, 255 )
sideBar.x = 0
sideBar.y = 0
mapView:insert(sideBar)

myMap = native.newMapView( 0, 0, screenWidth*0.7, screenHeight )
myMap:setReferencePoint(display.TopLeftReferencePoint)
myMap.x = sideBar.width
myMap.y = 0
mapView:insert(myMap)

myLocation = myMap:getUserLocation()
myLatitude = myLocation.latitude
myLongitude = myLocation.longitude
myMap:setCenter(myLatitude, myLongitude, true)
myMap.isLocationUpdating = true

local onBtnPress = function(event)
local id = tonumber(event.target.id)

if id == 1 then
myMap.mapType = “standard”
print("–> MapType is Standard")

elseif id == 2 then
myMap.mapType = “satellite”
print("–> MapType is Satellite")

elseif id == 3 then
myMap.mapType = “hybrid”
print("–> MapType is Hybrid")
end
return true;
end

end

startApp()
[/code] [import]uid: 65840 topic_id: 13016 reply_id: 313016[/import]

I would make line 62 something like:
myMap:setCenter( 37.265310, -121.816406 )

…and at line 68 or something insert a function:

function updateMap()
 local currentLocation = myMap:getUserLocation()
 local currentLatitude = currentLocation.latitude
 local currentLongitude = currentLocation.longitude
 myMap:setCenter( currentLatitude, currentLongitude, true ) 
end

… and finally just before you ‘end’ your startApp() function add:
timer.performWithDelay(1000,updateMap,0)

I think if you do this it should work. [import]uid: 78015 topic_id: 13016 reply_id: 55905[/import]