1. Creating image overlay -
var imageOverlay = Map.createImageOverlay({
boundsCoordinate: {
topLeft:{ latitude: 34.4311, longitude: -118.6012 },
bottomRight:{ latitude: 34.4194, longitude: -118.5912 },
},
image: 'overlay_park.png',
});
2. Add single image overlay -
mapview.addImageOverlays(imageOverlay);
3. Add multiple image overlay -
mapview.addImageOverlays([imageOverlay1, imageOverlay2]);
4. Remove single image overlay -
mapview.removeImageOverlay(imageOverlay);
5. Remove all image overlays -
mapview.removeAllImageOverlays();
Complete test case -
var Map = require('ti.map');
var win = Titanium.UI.createWindow();
var mountainView = Map.createAnnotation({
latitude:34.4448,
longitude:-118.5971,
title:"Appcelerator Headquarters",
subtitle:'Mountain View, CA',
pincolor:Map.ANNOTATION_RED,
myid:1 // Custom property to uniquely identify this annotation.
});
var mapview = Map.createView({
mapType: Map.STANDARD_TYPE,
region: {latitude:34.4248, longitude: -118.5971,
latitudeDelta:0.01, longitudeDelta:0.01},
animate:true,
regionFit:true,
userLocation:true,
annotations:[mountainView]
});
var imageOverlay = Map.createImageOverlay({
boundsCoordinate: {
topLeft:{ latitude: 34.4311, longitude: -118.6012 },
bottomRight:{ latitude: 34.4194, longitude: -118.5912 },
},
image: 'overlay_park.png',
});
var imageOverlay1 = Map.createImageOverlay({
boundsCoordinate: {
topLeft:{ latitude: 34.4511, longitude: -118.6012 },
bottomRight:{ latitude: 34.4394, longitude: -118.5912 },
},
image: 'image2.jpg',
});
mapview.addImageOverlays([imageOverlay, imageOverlay1]);
//mapview.addImageOverlay(imageOverlay);
setTimeout(function(e){
Ti.API.info("inside timer");
//mapview.removeAllImageOverlays();
mapview.removeImageOverlay(imageOverlay);
}, 5000);
win.add(mapview);
// Handle click events on any annotations on this map.
mapview.addEventListener('click', function(evt) {
Ti.API.info("Clicked " + evt.clicksource + " on " + evt.latitude + "," + evt.longitude);
});
win.open();