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;
1 2 3 4 5 | myLocation = myMap:getUserLocation() myLatitude = myLocation.latitude myLongitude = myLocation.longitude myMap:setCenter(myLatitude, myLongitude, true) myMap.isLocationUpdating = true |
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.