[TIMOB-13102] iOS: Method *setRegion* is not working anymore
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2013-03-22T19:34:23.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 3.1.0, 2013 Sprint 06 API, 2013 Sprint 06 |
| Components | iOS |
| Labels | regression, triage |
| Reporter | Rafael Kellermann Streit |
| Assignee | Vishal Duggal |
| Created | 2013-02-01T10:44:01.000+0000 |
| Updated | 2013-04-06T07:17:01.000+0000 |
Description
*Problem description*
The method setRegion in MapView is not causing any effect in MapView region.
Below is a code example of what happens: No one error occurs, but the MapView region doesn't change.
It works fine in 3.0.0.GA.
*Test case*
var win = Ti.UI.createWindow({
backgroundColor : "#FFF"
});
var map = Ti.Map.createView();
win.add(map);
// Change Region of MapView, this method is not working
map.setRegion({
latitude : -29.688053,
longitude : -52.03125,
latitudeDelta : 0.005,
longitudeDelta : 0.005
});
win.open();
Any updates here? This is a critical bug, IMHO.
Tested and confirmed issue with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130312161655 and 3.0.0.GA Device: iPhone5 iOS 6.0
This seems to be a timing issue. We will investigate why this is occurring. If you add the map to the window before trying to set the region, or if you set a timeout, or if you set the region at creation then change it once the map is added to the window, it works. here are some samples that worked for me:
var win = Ti.UI.createWindow({ backgroundColor : "#FFF" }); var map = Ti.Map.createView(); win.add(map); setTimeout(function(){ map.setRegion({ latitude : -29.688053, longitude : -52.03125, latitudeDelta : 0.005, longitudeDelta : 0.005 }); }, 500); win.open();var win = Ti.UI.createWindow({ backgroundColor : "#FFF" }); var regionAtlanta = {latitude:33.74511,longitude:-84.38993,latitudeDelta:0.04, longitudeDelta:0.04}; var boston = {latitude:42.334537,longitude:-71.170101,latitudeDelta:0.010, longitudeDelta:0.018}; var map = Ti.Map.createView({ mapType: Titanium.Map.STANDARD_TYPE, region: boston, regionFit:true }); var button= Ti.UI.createButton({ title:"Click me", top: 15 }); map.setRegion({latitude:42.334537,longitude:-71.170101,latitudeDelta:0.010, longitudeDelta:0.018}); win.add(map); win.add(button); button.addEventListener('click', function(){ map.setRegion({latitude:33.74511,longitude:-84.38993,latitudeDelta:0.04, longitudeDelta:0.04}); }); win.open();var win = Ti.UI.createWindow({ backgroundColor : "#FFF" }); var map = Ti.Map.createView(); win.add(map); win.open(); map.setRegion({ latitude : -29.688053, longitude : -52.03125, latitudeDelta : 0.005, longitudeDelta : 0.005 });Pull pending https://github.com/appcelerator/titanium_mobile/pull/4002
setRegion method is working fine as expected. Verified on: Device : iPad mini, iOS version: 6+ SDK: 3.1.0.v20130405170202 CLI version : 3.1.0-beta OS : MAC OSX 10.7.5 Appcelerator Studio, build: 3.1.0.201304011603