blank map on my google maps v2 for android titaniu

2019-08-30 14:08发布

问题:

I am using the titanium Goggle Maps v2 for Android (version 2.1.3.) and I am using Titanium studio 3.1.3.201309132423.

The sample code in the app.js file in the example folder IS WORKING for me.

However, when I am trying to create my own map, I am receiving the Google logo, the zoom in and zoom out button, and the button, which takes a user to their current position. The map itself is BLANK however. THIS WAS working for me at first and stopped all of a sudden.

I am using the switch statement which appears in the appcelerator docs for the module i.e.

var rc = MapModule.isGooglePlayServicesAvailable();
    switch (rc) {
        case MapModule.SUCCESS:
            Ti.API.info('Google Play services is installed.');
            break;
        case MapModule.SERVICE_MISSING:
            alert('Google Play services is missing. Please install Google Play services from the Google Play store.');
            break;
        case MapModule.SERVICE_VERSION_UPDATE_REQUIRED:
            alert('Google Play services is out of date. Please update Google Play services.');
            break;
        case MapModule.SERVICE_DISABLED:
            alert('Google Play services is disabled. Please enable Google Play services.');
            break;
        case MapModule.SERVICE_INVALID:
            alert('Google Play services cannot be authenticated. Reinstall Google Play services.');
            break;
        default:
            alert('Unknown error.');
            break;
    }

and my log IS REPORTING BACK THE 1ST CASE THAT GOOGLE PLAY SERVICES IS INSTALLED

My ti.App.xml is the following:

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.girt.MyApp</id>
    <name>MyApp</name>
    <version>1.0</version>
    <publisher>roseanne</publisher>
    <url>http://www.apps.com</url>
    <description>not specified</description>
    <copyright>2014 by roseanne</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>true</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>true</navbar-hidden>
    <analytics>true</analytics>
    <guid>78be39e9-acb5-469f-9fa2-3724280dee14</guid>
    <property name="ti.ui.defaultunit" type="string">system</property>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
                <!-- <uses-sdk android:targetSdkVersion="11"/> -->
            <!-- 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"/>  
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

            <!-- 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.girt.Myapp.permission.MAPS_RECEIVE"/>
            <permission android:name="com.girt.Myapp.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="xxxxxxxxxxxxxxx"/>
            </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" version="1.1">com.gbaldera.titouchgallery</module> 
        <module platform="android" version="0.1">titutorial.ratingbar</module>
        <module platform="android" version="2.1.3">ti.map</module>
    </modules>
    <deployment-targets>
        <target device="iphone">false</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.1.GA</sdk-version>
</ti:app>

If anyone could please help, I've been working on this for two days and have not come to a solution. The most frustrating part about it, is that it WAS working, and then stopped.

回答1:

After a ful day of frustration, I spotted that when I pressed the back button, I could just about see a translucent map for a split second. I changed the zIndex and no difference. I then changed the backgroundColor of the window to 'transparent' and voila



回答2:

I also had this problem, and the solutions here were not fully effective. Here's one more thing to try and I hope it works for you. You need to actually 'Enable' the api as well as create it. I had only created it.

To do this go to the google console Click on the "Google Maps Android API" Click to enable it.

Then relaunch your app from within appcelerator. Finally, some action.

Good luck!