Skip to content

Instantly share code, notes, and snippets.

@codeboxed
Created October 14, 2011 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeboxed/1287231 to your computer and use it in GitHub Desktop.
Save codeboxed/1287231 to your computer and use it in GitHub Desktop.
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