谷歌地图v2模块. Android应用程序未在地图视图中显示地图
作者:互联网
我正在使用新的Google map v2模块在我的Android应用程序中显示地图.我正在做以下步骤.应用程序安装和工作正常.我面临的问题是视图中没有地图.
1)首先我已下载地图模块并放入下面的文件夹.
/Users/fkamani/Library/Application\ Support/Titanium/modules/android/
2)在tiapp.xml文件中添加map模块.
<module platform="android">ti.map</module>
3)在tiapp.xml中添加以下android清单
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<!-- 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.mycompanyname.myprojectname.permission.MAPS_RECEIVE"/>
<permission android:name="com.mycompanyname.myprojectname.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="My App key"/>
</application>
</manifest>
</android>
4)改变Titamium sdk版本.
<sdk-version>3.0.2.GA</sdk-version>
5)从钛文档中复制下面的代码并放入app.js文件中
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)我创建了新的密钥库文件,并使用此密钥库文件创建分发构建.
7)为了创建谷歌地图API密钥,我在控制台中复制了SHA1证书指纹; com.mycompanyname.myprojectname.
应用程序已成功安装在我的Samsung S3设备中.当我运行应用程序时,它显示地图视图, – 缩放按钮.唯一的问题是地图视图中没有地图.
解决方法:
在移动设备上编译时检查Studio控制台,并查找:
[DEBUG] jarsigner -sigalg MD5withRSA -digestalg SHA1 -storepass ******* -keystore "YOUR_PATH_TO_KEYSTORE" -signedjar
如果密钥库位于“… / mobilesdk / osx / 3.0.2.GA / android / dev_keystore”中,则需要使用dev_keystore的SHA1证书创建google maps API密钥.
这对我有用.
标签:android,google-maps-api-2,titanium-mobile 来源: https://codeday.me/bug/20190703/1370719.html