Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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)

— asked March 18th 2010 by Gregoire Marchal
  • location
  • map
  • mapview
  • region
0 Comments

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

    — answered November 20th 2010 by Werner Bogula
    permalink
    1 Comment
    • it works for me…

      thnx

      — commented January 9th 2012 by Mitul Bhalia
  • 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);

    — answered January 12th 2012 by Darren Cope
    permalink
    0 Comments
  • 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};

    — answered March 18th 2010 by Nolan Wright
    permalink
    0 Comments
  • 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
    
    — answered March 19th 2010 by Gregoire Marchal
    permalink
    0 Comments
  • 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).

    — answered April 1st 2010 by Mike Edwards
    permalink
    0 Comments
  • There is currently an issue with setLocation() on android. Follow this ticket

    — answered November 4th 2010 by Paul Dowsett
    permalink
    0 Comments
  • I think this problem still exists in 1.8.x ?

    — answered April 14th 2012 by Oscar Kneib
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.