I am using the new Google map v2 module to display maps in an Android application. I am doing the following steps. The application installs and works fine. The problem I am facing is the lack of a map inside the view.
1) First, I downloaded the card module and placed it in the following folder.
/Users/fkamani/Library/Application\ Support/Titanium/modules/android/
2) Add the map module to the tiapp.xml file.
<module platform="android">ti.map</module>
3) Add the following android manifest in tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <uses-permission android:name="com.mycompanyname.myprojectname.permission.MAPS_RECEIVE"/> <permission android:name="com.mycompanyname.myprojectname.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <application> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="My App key"/> </application> </manifest> </android>
4) change the version of Titamium sdk.
<sdk-version>3.0.2.GA</sdk-version>
5) Copy the code below from the documentation for titanium and place it in the app.js file
var MapModule = require('ti.map'); var win = Titanium.UI.createWindow(); var mountainView = MapModule.createAnnotation({ latitude:37.390749, longitude:-122.081651, title:"Appcelerator Headquarters", subtitle:'Mountain View, CA', pincolor:MapModule.ANNOTATION_RED, myid:1 // Custom property to uniquely identify this annotation. }); var mapview = MapModule.createView({ mapType: MapModule.NORMAL_TYPE, region: {latitude:33.74511, longitude:-84.38993, latitudeDelta:0.01, longitudeDelta:0.01}, animate:true, regionFit:true, userLocation:true, annotations:[mountainView] }); win.add(mapview); // Handle click events on any annotations on this map. mapview.addEventListener('click', function(evt) { Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid); }); win.open();
6) I created a new keystore file and used this keystore file to create a distribution assembly.
7) To create the Google Maps APIs, I have a copy of the SHA1 certificate, com.mycompanyname.myprojectname in the console.
The application was successfully installed on my Samsung S3 device. When I launch the application, it displays a map with the +, - button to enlarge it. The only problem is the lack of displaying the map inside the map.