简体   繁体   中英

Eclipse Android Project - Google Maps won't update when zooming in

Hi guys I've got a problem :S My map literally won't update when I zoom into it, it would look like this but without the street names. 在此处输入图片说明

I'm using eclipse to build this App and I test it using a tablet which runs on Android 4.0.4. I've added in one Marker just to test that out if you're wondering why the default code for a marker is there.

The code for the App is as follows:

MainActivity.Java:

    package com.Chris.MyMap;

      import com.google.android.gms.maps.GoogleMap;
      import com.google.android.gms.maps.MapFragment;
      import com.google.android.gms.maps.model.LatLng;
      import com.google.android.gms.maps.model.MarkerOptions;
      import android.os.Bundle;
      import android.app.Activity;
      import android.view.Menu;

      public class MainActivity extends Activity {

private GoogleMap Map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    Map.addMarker(new MarkerOptions()
                .position(new LatLng( 0,0))
                .title("Hello World"))
                .setSnippet("Helllllllllllooooooooo");

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

      }

Manifest:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.Chris.MyMap"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

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

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.Chris.MyMap.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
    Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

    <application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="5t5dAj8l_t67aaaaaawyqJeYuWuaaaaaaaa"/>

    <activity
        android:name="com.Chris.MyMap.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
       </activity>
      </application>

      </manifest>

activity_main.xml:

      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" >

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

      </RelativeLayout>

I'm not sure what else I can do, I've installed google play services, all the Google Api's, I tried FragmentActivity and SupportMapFragment but the app could never load. Does anyone know anything else I could try

Any help would be appreciated!

-Chris

You should have this in your AndroidManifest.xml:

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

Instead of this:

<uses-permission android:name="com.Chris.MyMap.gsf.permission.READ_GSERVICES"/>

I have it like that in my app and it works fine. Also, look here: https://developers.google.com/maps/documentation/android/start#specifying_permissions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM