Hello, there is something i don't understand with mapView. The region is our current screen position no? I need to get my current screen location but when i add a button to get my mapview.region.latitute for exemple, it is always the same :/ . Maybe region is not what am thinking?
So how to get my current screen location? I added a button in KitchenSink example too and the problem is the same :(
Thank you
2 Answers
Accepted Answer
When you create a mapview using Titanium.Map.createView that mapview will fire the event 'regionChanged' when the user drags the map, or the map is moved programatically. You can listen for that event, and the region data is passed into the callback method.
Ti.Map.View regionChanged event documentation
Try something like this (where mapview is created with Ti.Map.createView):
mapview.addEventListener("regionChanged",function(e){ Ti.API.info(JSON.stringify(e)); currentPositon = {latitude:e.latitude, longitude:e.longitude}; });
The region is a dictionary with center of map (lat/lng) and the diff between the lat of left corner and lat of right corner. The similar for longitudedelta.
Hope this helps
Rainer
Your Answer
Think you can help? Login to answer this question!