钛地图api,地图不加载

时间:2014-09-09 06:58:13

标签: javascript android google-maps titanium

它加载了gui,我可以按下我的位置,我基本上在地图上看到自己,也是一个蓝点。我也看到了注释,但地图本身仍然是灰色的。我有互联网连接。我使用以下代码: Map.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
});

var eentweedrie = MapModule.createAnnotation({
    latitude:51.32811396764682,
    longitude:3.850465540405268,
    title:"school",
    subtitle:'terneuzen',
    pincolor:MapModule.ANNOTATION_RED
});



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, eentweedrie]
});
win.add(mapview);
win.open();

tiapp.xml

<?xml version="1.0" encoding="UTF-8"?><ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.Innovisionsolutions.com</id>
    <name>mbo app</name>
    <version>5.64.15</version>
    <publisher>IVS</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>2014 by IVS</copyright>
    <icon>logo.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>true</statusbar-hidden>
    <fullscreen>true</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>d39ece47-4841-4499-a992-b8788db55848</guid>
    <property name="ti.ui.defaultunit" type="string">system</property>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <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"/>
            <uses-permission android:name="com.innovisionsolutions.com.permission.MAPS_RECEIVE"/>
            <permission android:name="com.innovisionsolutions.com.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="AIzaSyAxgb4M6UEszyMstdTvak_AmQDRo0xItNA"/>
            </application>
        </manifest>
    </android>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules>
        <module platform="android">ti.map</module>
    </modules>
    <deployment-targets>
        <target device="iphone">true</target>
        <target device="ipad">false</target>
        <target device="android">true</target>
        <target device="blackberry">false</target>
        <target device="mobileweb">true</target>
        <target device="tizen">false</target>
    </deployment-targets>
    <sdk-version>3.1.2.GA</sdk-version>
    <property name="ti.deploytype">test</property>
</ti:app>

我已经检查了密钥,并且与我的api帐户相同。

有人可以帮助我并加载此地图吗?

提前致谢!!! :d

1 个答案:

答案 0 :(得分:0)

首先,您必须更改tiapp.xml文件的Android清单部分中的以下行,将 com.innovisionsolutions.com 替换为实际应用程序的ID (包名称) com.Innovisionsolutions.com

<uses-permission android:name="com.Innovisionsolutions.com.permission.MAPS_RECEIVE"/>
<permission android:name="com.Innovisionsolutions.com.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

之后,您必须按照以下模式创建新的Google Maps API Android密钥:

  

[cert_fingerprint]; [package_name] AKA [您的密钥库的SHA1   指纹]; [您的应用程序的正确区分大小写的ID]

例如:

  

45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;的 com.Innovisionsolutions。 COM

最后,替换创建的Android API密钥:

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="PASTE YOUR GOOGLE MAPS API KEY HERE"/>