0

當地方選擇器啓動時,附近的地點列表應顯示在旁邊的地方有一個3-5秒長的加載圓圈動畫。加載循環消失後,列表中不會顯示附近的地點,地圖上也不會顯示附近的地點引腳。Android Google Place Picker:沒有附近的地方,直到地圖平鋪

現在,如果在任何方向平移地圖(縮放不做任何事情)的數量相當可觀,那麼附近的地方加載就好了。

下面的第一張圖片是在地方選擇器啓動後拍攝的,它會保持這種方式,不會加載任何附近的地方,直到我平移地圖。

第二張圖片是我在平鋪地圖後拍攝的,其中附近的地方正確加載。

底部是我的相關代碼,讓我知道如果你需要更多。

Before panning the map After panning the map

<manifest 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 
    <application 
     <meta-data 
      android:name="com.google.android.geo.API_KEY" 
      android:value="MY_API_KEY" /> 
     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
    </application> 
</manifest> 

// Emulator is using google play services version 9.4.52 
dependencies {  
    compile 'com.google.android.gms:play-services-maps:9.4+' 
    compile 'com.google.android.gms:play-services-places:9.4+' 
    compile 'com.google.android.gms:play-services-location:9.4+' 
} 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    mGoogleApiClient = new GoogleApiClient 
      .Builder(this) 
      .addApi(Places.GEO_DATA_API) 
      .addApi(Places.PLACE_DETECTION_API) 
      .enableAutoManage(this, this) 
      .build(); 
} 

public void choosePlace() { 
    try { 
     PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder(); 
     Intent intent = intentBuilder.build(this); 
     startActivityForResult(intent, PLACE_PICKER_REQUEST); 
    } catch (GooglePlayServicesRepairableException e) { 
     // This is not being thrown 
    } catch (GooglePlayServicesNotAvailableException e) { 
     // This is not being thrown 
    } 
} 

@Override 
public void onConnectionFailed(ConnectionResult result) { 
    // This is not being called 
} 
+0

如果你回到你當前的位置平移了地圖後會發生什麼?換句話說,它是否不會爲您的當前位置提供結果,還是僅在第一次失敗? – AndrewR

+0

TL; DR: 當地圖以我的當前位置爲中心或與其非常接近時,它永遠不會加載附近的地方。 我沒有想到這種行爲,但在這裏它是: 當從我目前的位置平移,我得到的地方我平移到。如果我平移回我的位置,或者非常靠近它,那麼我的當前位置周圍不會加載任何地方。此外,如果我平移並使用晶圓廠回到我的位置,沒有地方加載。 感謝您提出此澄清。 – user1968412

回答

0

你加這個?

<meta-data    
    android:name="com.google.android.geo.API_KEY" 
    android:value="your_key" /> 

我有同樣的問題,因爲我忘了元數據添加到我的清單

+0

是的,我已添加 – user1968412