Instantly share code, notes, and snippets.

Embed
What would you like to do?
function mapview(_args) {
var win = Titanium.UI.createWindow({
title:_args.title
});
var isAndroid = false;
var MapModule = Titanium.Map;
var MapType = MapModule.STANDARD_TYPE;
if (Titanium.Platform.name == 'android') {
isAndroid = true;
MapModule = require('ti.map');
MapType = MapModule.NORMAL_TYPE;
}
//
// CREATE MAP VIEW
//
var mapview = MapModule.createView({
mapType: MapType,
region:{latitude:35.68066, longitude:139.76749, latitudeDelta:0.015, longitudeDelta:0.015},
animate:true,
regionFit:true,
userLocation:true,
});
win.add(mapview);
//
// EVENT LISTENERS
//
// region change event listener
var regionchanged = 'regionChanged';
if (Ti.version >= '3.0.0') {
regionchanged = 'regionchanged';
}
mapview.addEventListener(regionchanged,function(evt){
Titanium.API.info('regionchange '+evt.longitude+','+evt.latitude);
});
return win;
};
module.exports = mapview;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment