Titanium Community Questions & Answer Archive

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

Map region doesn't fit in MapView of Titanium when catch event 'regionChanged'

I write a demo mapview in Titanium (iPhone). Here's the code I get from KitchenSink:

var win = Titanium.UI.currentWindow;
var annotation = Titanium.Map.createAnnotation({
    latitude:42.334537,
    longitude:-71.170101,
    title:"Boston College",
    subtitle:'Newton Campus, Chestnut Hill, MA',
    animate:true,
    leftButton:'../images/atlanta.jpg'
});

var boston = {latitude:42.334537,longitude:-71.170101,latitudeDelta:0.010, longitudeDelta:0.018};

//
// CREATE MAP VIEW
//
var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    region: boston,
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[annotation]
});

win.add(mapview);

It runs well on both iPhone Simulator as well as in real phone. The problem is, when I catch event 'regionChanged', the map region is wrong. My code is:

var win = Titanium.UI.currentWindow;

var annotation = Titanium.Map.createAnnotation({
    latitude:42.334537,
    longitude:-71.170101,
    title:"Boston College",
    subtitle:'Newton Campus, Chestnut Hill, MA',
    animate:true,
    leftButton:'../images/atlanta.jpg'
});

var boston = {latitude:42.334537,longitude:-71.170101,latitudeDelta:0.010, longitudeDelta:0.018};

//
// CREATE MAP VIEW
//
var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    region: boston,
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[annotation]
});

win.add(mapview);

// map view click event listener
mapview.addEventListener('regionChanged',function(evt)
{

});

In this event, I even didn't write anything. But now, the map zoom level is suddenly maximum. (Oh, it's normal in Simulator, so please check in real phone to see this bug). Although I set latitudeDelta=1, the zoom level of map is still zoom-in maximum as if latitudeDelta=0.001.

So, what's the root of this bug? Anyone can help me?

— asked November 8th 2010 by Triet BuiMinh
  • mapview
  • regionchanged
0 Comments

3 Answers

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.