Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
android menu
if (isAndroid) {
var myLocation = null;
var centerEdinburgh = null;
var sat = null;
var std = null;
var menuClickHandlers = function() {
myLocation.addEventListener('click', function() {
Ti.Geolocation.getCurrentPosition(function(e) {
var region = {
latitude : e.coords.latitude,
longitude : e.coords.longitude,
animate : true,
latitudeDelta : 0.001,
longitudeDelta : 0.001
};
Ti.API.info(region);
mapView.setLocation(region);
});
});
centerEdinburgh.addEventListener('click', function() {
Ti.API.info('Center on Edinburgh');
mapView.setLocation(defaultCoords);
});
sat.addEventListener('click', function() {
mapView.setMapType(Ti.Map.SATELLITE_TYPE); //On android is the same as Hybrid
});
std.addEventListener('click', function() {
mapView.setMapType(Ti.Map.STANDARD_TYPE);
});
};
var activity = Ti.Android.currentActivity;
activity.onCreateOptionsMenu = function(e) {
var menu = e.menu;
myLocation = menu.add({
title : 'My Location'
});
centerEdinburgh = menu.add({
title : 'Reset'
});
sat = menu.add({
title : 'Satellite'
});
std = menu.add({
title : 'Standard'
});
menuClickHandlers();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.