Mapview region not refreshed upon dynamically assigning location coordinates

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

Hello, I'm using Geocoder to to translate the address, given through a text field, in terms of latitude and longitude and then set the map region to that location as follows.

var location = Titanium.UI.createTextField({...});
var btnSearch = Titanium.UI.createButton({...});
var mapview = Titanium.Map.createView({
    top: 75,    height: 350,
    mapType: Titanium.Map.SATELLITE_TYPE,
    animate: true,  regionFit: true,    userLocation: true
});
btnSearch.addEventListener('click',function(e){
    if(location.value != '') {
        Ti.Geolocation.forwardGeocoder(location.value, function(e){
            Ti.API.info(location.value + '\'s co-ordinates are: ' + e.latitude + ' lat, ' + e.longitude + ' lon');
            mapview.region = {latitude: e.latitude, longitude: e.longitude, latitudeDelta:0.1, longitudeDelta:0.1};
        });
    } 
    else {
        alert('You must provide a start address!');
    }
});
The translation process works fine but the map region is not set to new coordinates in mapview. If anybody knows the cause of this problem, please help me.

Application type: Mobile

Titanium SDK: 2.x

Platform & version: Android 2.2

Device: Android emulator

Host Operating System: Windows XP

Titanium Studio: build: 2.1.0.201206251749 Build: jenkins-titanium-rcp-master-218 (origin/master) Date: 25 June 2012, 17:50:34

Thanks.

— asked 10 months ago by Ammar Asim
0 Comments

1 Answer

Accepted Answer

I have also had problems with setting the region on android. Try setLocation() instead and see if it works.

Your Answer

This question has been locked and cannot accept new answers.