Can we update the mapview region/location?
I'd like to add a button on a mapview that changes the region displayed by the map (using geolocation or text address).
I've tried to update the mapview.region property, and then the mapview.location property, but both properties don't update the mapview, nothing happens.
Is there a way to do that?
(tested on android)
7 Answers
-
Hi folks,
this bugged me for hours. Did not work for iPhone and Android.
Finally I chose the brute force method, which works for both platforms:var region1 = {
latitude:latitude,
longitude:longitude,
animate:true,
latitudeDelta:0.002,
longitudeDelta:0.002
};mapview.hide(); mapview.setLocation(region1); mapview.show();
hope it helps, until someone gets the setLocation()-method fixed…
Werner
-
This works in version 1.7.5 on android and without need for the brute force method shown above.
var newRegion = {latitude:42.234528, longitude:-1.423687, latitudeDelta:0.01, longitudeDelta:0.01};
theMap.setLocation(newRegion); -
look at Kitchen Sink (map_view.js). you use setLocation and location is an object with the following properties:
{latitude:33.74511,longitude:-84.38993,animate:true,latitudeDelta:0.04, longitudeDelta:0.04};
-
It doesn't seem to work on android, nothing changes on display… (can't test on iphone)
button.addEventListener('click',function() { Titanium.API.debug('changing region'); mapview.setLocation({latitude:45.6372, longitude:4.0629, latitudeDelta:0.05, longitudeDelta:0.05, animate:false}); Titanium.API.debug('region changed'); });
[DEBUG] [7115,12974] changing region [TRACE] I/KrollObject( 305): (kroll$2) [99,13073] Treating as dynamic property: setLocation [TRACE] I/TiUIView( 305): (main) [5,13078] Unhandled property key: location [DEBUG] [3,13081] region changed
-
I have the same results. Nothing changes when I use setLocation or when I set the location property on Android (Titanium 1.1.2, Android API 2.1).
-
There is currently an issue with setLocation() on android. Follow this ticket
-
I think this problem still exists in 1.8.x ?