Mapview: How to update region?

You must Login before you can answer or comment on any questions.

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

— asked 11 months ago by jeremie m
0 Comments

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

— answered 11 months ago by Rainer Schleevoigt
answer permalink
1 Comment
  • Thanks for your answer! So, if i change my position, the region will always be the same? How to get the value of my screen center position?

    — commented 11 months ago by jeremie m

Your Answer

Think you can help? Login to answer this question!