Created
December 6, 2013 14:04
-
-
Save mogya/7824304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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