Created
October 20, 2012 09:06
-
-
Save addieljuarez/3922730 to your computer and use it in GitHub Desktop.
geolocation android ios
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 ApplicationWindow() { | |
//load component dependencies | |
var FirstView = require('ui/common/FirstView'); | |
//create component instance | |
var self = Ti.UI.createWindow({ | |
backgroundColor:'#ffffff' | |
}); | |
Titanium.Geolocation.distanceFilter = 10; | |
Titanium.Geolocation.getCurrentPosition(function(e) | |
{ | |
if (e.error) | |
{ | |
//if mapping location doesn't work, show an alert | |
alert('Sorry, but it seems geo location is not available on your device!'); | |
return; | |
} | |
//get the properties from Titanium.GeoLocation | |
var longitude = e.coords.longitude; | |
var latitude = e.coords.latitude; | |
var altitude = e.coords.altitude; | |
var heading = e.coords.heading; | |
var accuracy = e.coords.accuracy; | |
var speed = e.coords.speed; | |
var timestamp = e.coords.timestamp; | |
var altitudeAccuracy = e.coords.altitudeAccuracy; | |
//apply the lat and lon properties to our mapview | |
var mapView = Ti.Map.createView({ | |
mapType:Ti.Map.STANDARD_TYPE, | |
userLocation:true, | |
regionFit:true, | |
animate:true, | |
}); | |
mapView.region = {latitude: latitude, | |
longitude: longitude, | |
latitudeDelta:0.05, | |
longitudeDelta:0.05 | |
}; | |
self.add(mapView); | |
}); | |
return self; | |
} | |
//make constructor function the public component interface | |
module.exports = ApplicationWindow; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment