Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cstrap/4988308 to your computer and use it in GitHub Desktop.
Save cstrap/4988308 to your computer and use it in GitHub Desktop.
var currentWin = Ti.UI.currentWindow;
// below example would require variable declarations for Name, Description, image, Lat, Longitude
// Docs:
// http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.Annotation-object
// http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object
//
// CREATE MAP VIEW
//
var mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region:{latitude:Lat, longitude:Longitude, latitudeDelta:0.008, longitudeDelta:0.008},
animate:true,
regionFit:true,
userLocation:true,
});
// create an annotation
// note: appears to be no way to fire event from marker pin, only the annotation (caption)?
// note: is there any way to style (color, text alignment, transparency?) the annotation (caption) in Android?
var marker = Titanium.Map.createAnnotation({
animate:true,
title:Name, //works in Android
subtitle:Description, //works in Android
leftView:image, // doesn't work in Android, either passing view object or image?
rightButton:'../icons/marker.png', //doesn't work in Android, either image or button object?
latitude:parseFloat(Lat), //works
longitude:parseFloat(Longitude), //works
image:'../icons/marker.png', //*does* work in Android! Creates drop-shadow automagically
myid:3
});
mapview.addAnnotation(marker);
currentWin.add(mapview);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment