Skip to content

Instantly share code, notes, and snippets.

@egomez99
Created February 3, 2012 18:44
Show Gist options
  • Save egomez99/1731688 to your computer and use it in GitHub Desktop.
Save egomez99/1731688 to your computer and use it in GitHub Desktop.
An Annotation in iOS
var win = Ti.UI.createWindow();
//
// CREATE ANNOTATIONS
//
var atlantaParams = {
latitude:33.74511,
longitude:-84.38993,
//title:"Atlanta, GA",//uncomment to show the Bubble normally
subtitle:'Atlanta Braves Stadium\nfoo',
animate:true,
rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE,
myid:3
};
atlantaParams.pincolor = Titanium.Map.ANNOTATION_PURPLE;
var atlanta = Titanium.Map.createAnnotation(atlantaParams);
//
// PRE-DEFINED REGIONS
//
//
// CREATE MAP VIEW
//
var mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region:{latitude:33.74511, longitude:-84.38993, latitudeDelta:0.5, longitudeDelta:0.5},
animate:true,
regionFit:true,
userLocation:true
});
win.add(mapview);
mapview.addAnnotation(atlanta);
atlanta.addEventListener('click', function(evt) {
var annotation = evt.annotation;
var clickSource = evt.clicksource;
mapview.selectAnnotation(atlanta);
Ti.API.info(JSON.stringify(annotation));
if(clickSource === 'pin') {
Ti.API.info('Pin clicked: '+clickSource);
}else if(clickSource === 'title'){
Ti.API.info('Title clicked: '+clickSource);
}
});
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment