简体   繁体   English

GoogleMap V2 android无法显示位置

[英]GoogleMap V2 android can't show Location

i just try with googlemaps v2 in android. 我只是尝试在Android中使用googlemaps v2。 and when i run it there's no error but the map can't show the place that i set from lat and long(displaying blank area). 当我运行它时没有错误,但是地图无法显示我从经纬度(显示空白区域)中设置的位置。 anyone can tell me me what suppose i do? 谁能告诉我我该怎么办? thank you very much. 非常感谢你。

this is the logcat 这是logcat

12-04 16:36:59.545: D/AbsListView(564): Get MotionRecognitionManager
12-04 16:36:59.545: D/AbsListView(564): onVisibilityChanged() is called, visibility : 8
12-04 16:36:59.550: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.550: D/AbsListView(564): onVisibilityChanged() is called, visibility : 8
12-04 16:36:59.550: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.560: D/AbsListView(564): onVisibilityChanged() is called, visibility : 0
12-04 16:36:59.560: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.575: D/AbsListView(564): onVisibilityChanged() is called, visibility : 4
12-04 16:36:59.575: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.585: D/AbsListView(564): onVisibilityChanged() is called, visibility : 0
12-04 16:36:59.585: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.650: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:36:59.710: D/dalvikvm(564): GC_FOR_ALLOC freed 219K, 52% free 5537K/11424K, paused 18ms, total 18ms
12-04 16:36:59.710: I/dalvikvm-heap(564): Grow heap (frag case) to 10.748MB for 131088-byte allocation
12-04 16:36:59.725: D/dalvikvm(564): GC_FOR_ALLOC freed <1K, 51% free 5664K/11556K, paused 18ms, total 18ms
12-04 16:36:59.750: E/dalvikvm(564): adjustAdaptiveCoef max=8388608, min=2097152, ut=568
12-04 16:36:59.750: D/AbsListView(564): [unregisterDoubleTapMotionListener]
12-04 16:36:59.750: D/dalvikvm(564): GC_FOR_ALLOC freed 152K, 53% free 5536K/11556K, paused 20ms, total 20ms
12-04 16:36:59.750: I/MotionRecognitionManager(564):   .unregisterListener : / listener count = 0->0,  
12-04 16:36:59.750: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:37:13.520: D/dalvikvm(564): GC_CONCURRENT freed 2060K, 58% free 5398K/12804K, paused 5ms+6ms, total 46ms
12-04 16:37:24.595: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:37:24.735: D/AbsListView(564): onVisibilityChanged() is called, visibility : 8
12-04 16:37:24.735: D/AbsListView(564): unregisterIRListener() is called 
12-04 16:37:24.750: D/AbsListView(564): onDetachedFromWindow
12-04 16:37:31.665: D/dalvikvm(564): GC_CONCURRENT freed 408K, 58% free 5385K/12804K, paused 9ms+4ms, total 71ms
12-04 16:37:31.665: D/AbsListView(564): [unregisterDoubleTapMotionListener]
12-04 16:37:31.665: I/MotionRecognitionManager(564):   .unregisterListener : / listener count = 0->0,  
12-04 16:50:04.020: E/dalvikvm(564): adjustAdaptiveCoef max=8388608, min=2097152, ut=568
12-04 16:37:31.665: D/AbsListView(564): unregisterIRListener() is called 

this is my mainactivity 这是我的主要活动

package unai.skripsi.mymaps;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

    static final LatLng RAGUNAN = new LatLng(-6.3039, 106.8267);
    static final LatLng TAMANMINI = new LatLng(-6.29436, 106.8859);
    private GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    map= ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    if (map!=null){
    Marker ragunan = map.addMarker(new MarkerOptions().position(RAGUNAN)
        .title("Ragunan"));
    Marker tamanmini = map.addMarker(new MarkerOptions().position(TAMANMINI)
        .title("Taman mini")
        .snippet("Taman mini itu indah")
        .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(RAGUNAN, 15));
    map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

    }
}


@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;
}

}

this is my AndroidManifest 这是我的AndroidManifest

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

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

<permission
    android:name="unai.skripsi.mymaps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="unai.skripsi.mymaps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="unai.skripsi.mymaps.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>
    <meta-data android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaKlACQ2LD6E2jd_AUDWLMB2AsasdwdadAsSRT" />
</application>

</manifest>

this is my layout activity_main 这是我的布局activity_main

<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"
tools:context=".MainActivity" >

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

</RelativeLayout>

go to google api console and turn on the Google Maps Android API v2 service 转到Google API控制台并打开Goog​​le Maps Android API v2服务

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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