Android Google Place Picker:没有附近的地方,直到地图平铺
问题描述:
当地方选择器启动时,附近的地点列表应显示在旁边的地方有一个3-5秒长的加载圆圈动画。加载循环消失后,列表中不会显示附近的地点,地图上也不会显示附近的地点引脚。Android Google Place Picker:没有附近的地方,直到地图平铺
现在,如果在任何方向平移地图(缩放不做任何事情)的数量相当可观,那么附近的地方加载就好了。
下面的第一张图片是在地方选择器启动后拍摄的,它会保持这种方式,不会加载任何附近的地方,直到我平移地图。
第二张图片是我在平铺地图后拍摄的,其中附近的地方正确加载。
底部是我的相关代码,让我知道如果你需要更多。
<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
}
答
你加这个?
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="your_key" />
我有同样的问题,因为我忘了元数据添加到我的清单
+0
是的,我已添加 – user1968412
如果你回到你当前的位置平移了地图后会发生什么?换句话说,它是否不会为您的当前位置提供结果,还是仅在第一次失败? – AndrewR
TL; DR: 当地图以我的当前位置为中心或与其非常接近时,它永远不会加载附近的地方。 我没有想到这种行为,但在这里它是: 当从我目前的位置平移,我得到的地方我平移到。如果我平移回我的位置,或者非常靠近它,那么我的当前位置周围不会加载任何地方。此外,如果我平移并使用晶圆厂回到我的位置,没有地方加载。 感谢您提出此澄清。 – user1968412