[TIMOB-28529] Android: Update "ti.map" module to support "camera" property and animateCamera()
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-09-01T00:33:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.1.0 |
Components | Android |
Labels | android, camera, parity, ti.map |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2021-08-31T19:50:14.000+0000 |
Updated | 2021-09-01T00:33:41.000+0000 |
Description
*Summary:*
iOS' version of the "ti.map" modules supports the ability to control the height, pitch, and rotation of the camera via the following APIs. We should add the same on Android.
* [MapView.camera](https://titaniumsdk.com/api/modules/map/view.html#camera) property
* [MapView.animateCamera()](https://titaniumsdk.com/api/modules/map/view.html#animatecamera) method
*Implementation:*
A community written PR has been made to do this by [~michael]. _(Thanks!)_
https://github.com/appcelerator-modules/ti.map/pull/451
*Animate Camera Test:*
This smoothly animates the camera to 2 different positions.
const Map = require('ti.map');
const window = Titanium.UI.createWindow();
const mapview = Map.createView({
mapType: Map.NORMAL_TYPE,
animate: false,
regionFit: true
});
window.add(mapview);
window.addEventListener('open', () => {
setTimeout(() => {
const camera = Map.createCamera({
altitude: 15.5,
centerCoordinates: { longitude: 151.276417, latitude: -33.891614 },
heading: -90,
pitch: 75
});
mapview.animateCamera({ camera: camera, duration: 5000 }, () => {
setTimeout(() => {
camera.centerCoordinates = { longitude: 151.20689, latitude: -33.87365 };
camera.heading = 90;
camera.pitch = 50;
mapview.animateCamera({ camera: camera });
}, 2000);
});
}, 2000);
});
window.open();
*Camera Property Test:*
This instantly moves the camera (without animation) to 2 different locations.
var Map = require('ti.map');
var win = Titanium.UI.createWindow();
var mapview = Map.createView({
mapType: Map.NORMAL_TYPE,
animate: false,
regionFit: true
});
var camera = Map.createCamera({
altitude: 15.5,
centerCoordinates: {
longitude: 151.276417,
latitude: -33.891614
},
heading: -90,
pitch: 75
});
setTimeout(function() {
mapview.camera = camera;
camera.centerCoordinates = {
longitude: 151.20689,
latitude: -33.87365
};
camera.heading = 90;
camera.pitch = 50;
setTimeout(function() {
mapview.camera = camera;
}, 6000)
}, 2000)
win.add(mapview);
win.open();
PR (ti.map): https://github.com/appcelerator-modules/ti.map/pull/451
FR Passed.