Created
January 2, 2014 18:52
-
-
Save csemrm/8224421 to your computer and use it in GitHub Desktop.
Map view in Titanium 3.2.0.GA http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map
This file contains hidden or 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
var MapModule = require('ti.map'); | |
var win = Ti.UI.createWindow({ | |
backgroundColor : 'white' | |
}); | |
Titanium.Geolocation.getCurrentPosition(function(e) { | |
if (e.error) { | |
alert('HFL cannot get your current location'); | |
return; | |
} | |
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; | |
Ti.API.info('e.coords' + JSON.stringify(e.coords)); | |
// | |
//CREATE MAP VIEW | |
// | |
var mapview = MapModule.createView({ | |
mapType : Titanium.Map.STANDARD_TYPE, | |
region : { | |
latitude : latitude, | |
longitude : longitude, | |
latitudeDelta : 0.01, | |
longitudeDelta : 0.01 | |
}, | |
animate : true, | |
regionFit : true, | |
userLocation : true, | |
// annotations:[annotation] | |
}); | |
win.add(mapview); | |
// Listen for click events. | |
mapview.addEventListener('regionchanged', function(e) { | |
alert(mapview.getRegion()); | |
}); | |
mapview.addEventListener('complete', function(e) { | |
alert('Complete'); | |
}); | |
}); | |
win.open(); |
This file contains hidden or 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
<android xmlns:android="http://schemas.android.com/apk/res/android"> | |
<manifest android:installLocation="auto"> | |
<!-- Allows the API to download data from Google Map servers --> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<!-- Allows the API to cache data --> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | |
<!-- Use GPS for device location --> | |
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
<!-- Use Wi-Fi or mobile connection for device location --> | |
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | |
<!-- Allows the API to access Google web-based services --> | |
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> | |
<!-- Specify OpenGL ES 2.0 as a requirement --> | |
<uses-feature android:glEsVersion="0x00020000" android:required="true"/> | |
<!-- Replace com.domain.appid with your application ID --> | |
<uses-permission android:name="com.mrt.qna.permission.MAPS_RECEIVE"/> | |
<permission | |
android:name="com.mrt.qna.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> | |
<application> | |
<!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained --> | |
<meta-data | |
android:name="com.google.android.maps.v2.API_KEY" android:value="PASTE YOUR GOOGLE MAPS API KEY HERE"/> | |
</application> | |
</manifest> | |
</android> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment