Issue
When working on mobile web and using ti.map if the map visible property is set to false and the is set to true again the map will be reloaded to the original state instead of keeping the same location and zoom.
Steps to repro
1. Run test code
2. Move and zoom in the map view
3. Click on the toggle button to hide it
4. Click on the toggle button to show it
Expected Result
The map will be shown again with the last location and zoom
Actual Result
The map is reloaded to the original state
Test code
var win = Ti.UI.createWindow({
layout:'vertical'
});
var bt = Ti.UI.createButton({
top:20,
title:'Toggle'
});
var map = Ti.Map.createView({
visible:true,
top:20,
userLocation:true
});
Ti.Geolocation.MobileWeb.locationTimeout = 10000;
Ti.Geolocation.getCurrentPosition(locationCallback);
function locationCallback(e) {
console.log(e);
}
var last;
bt.addEventListener('click',function(){
map.visible = !map.visible;
});
win.add(bt);
win.add(map);
win.open();
Master pull request: https://github.com/appcelerator/titanium_mobile/pull/6380
Works as expected using the original code on the ticket. The code from Ingo doesn't work for me, however. Each time I hide/show the map I get different coordinates. If I understand his comments correctly, though, that's expected and isn't a valid test for this change.
Verified fix on: Mac OSX 10.10.1 Appcelerator Studio, build: 3.4.1.201410281743 Titanium SDK build: 3.6.0.v20150116070927 Titanium CLI, build: 3.4.1 Alloy: 1.5.1 Google Chrome iPhone 6 Plus (8.1.1) Built and packaged using the app.js provided, when viewing from browser and device then zooming and toggling, the map always stays zoomed. Closing ticket.