문제

So I've been trying to get a mapview to show up in my app but when I run it, the map doesn't load.

I've been following the "MapView Tutorial" on the android developer page. https://developers.google.com/maps/documentation/android/v1/hello-mapview

Any ideas on what I'm doing wrong?? Thanks for looking.

Below is the manifest.

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

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


<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.google.android.providers.gsf.permission.READ_GSERVICES"/>



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

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


    <application

        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
       >

        <uses-library android:name="com.google.android.maps" />


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




        <activity
            android:name="com.it.maps.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>

Below is the xml file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment"
    android:orientation="vertical" >



    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Derek's test map" />

    <com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/themap"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="AIzaSyDgs5B5g2oizaQauB6yieC6aCp5-z0zrfc"

/>




</LinearLayout>

And this is my class.

import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;


public class MainActivity extends MapActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        MapView view = (MapView) findViewById(R.id.themap);
        view.setBuiltInZoomControls(true);


    }





    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}
도움이 되었습니까?

해결책

You are using Google map v1 which is no longer been maintained and deprecated. Switch over to Google map v2.

https://developers.google.com/maps/documentation/android/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top