Android 在google PlacePicker中显示特定区域

Android 在google PlacePicker中显示特定区域,android,gmsplacepicker,Android,Gmsplacepicker,我正在开发一个android应用程序,它要求用户选择他/她的位置。我正在使用谷歌的PlacePikcerAPI来实现这一点。它工作正常,但我想在单击PlacePicker按钮时显示一个特定区域。例如,当我启动placepicker intent时,它应该显示特定区域或半径的地图,以使搜索更加具体。 我找了很多,但找不到路。请帮助。您可以尝试以下方法 LatLng bottomLeft = new LatLng(**bottom left latitude** , **bottom left lo

我正在开发一个android应用程序,它要求用户选择他/她的位置。我正在使用谷歌的PlacePikcerAPI来实现这一点。它工作正常,但我想在单击PlacePicker按钮时显示一个特定区域。例如,当我启动placepicker intent时,它应该显示特定区域或半径的地图,以使搜索更加具体。
我找了很多,但找不到路。请帮助。

您可以尝试以下方法

LatLng bottomLeft = new LatLng(**bottom left latitude** , **bottom left longitude**);
LatLng topRight = new LatLng(**top right latitude** , **top right longitude**);

LatLngBounds bounds = new LatLngBounds(bottomLeft ,topRight);


PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
intentBuilder.setLatLngBounds(bound);

// now use intentBuilder to build intent.

左下纬度左下经度标记要显示区域的左下角,并右上纬度右上经度标记区域的右上角。

您可以尝试以下方法

LatLng bottomLeft = new LatLng(**bottom left latitude** , **bottom left longitude**);
LatLng topRight = new LatLng(**top right latitude** , **top right longitude**);

LatLngBounds bounds = new LatLngBounds(bottomLeft ,topRight);


PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
intentBuilder.setLatLngBounds(bound);

// now use intentBuilder to build intent.

左下纬度左下经度标记要显示区域的左下角,并右上纬度右上经度标记区域的右上角。

谢谢。。它确实帮助了很多。是否也可以只添加一个
LatLng
作为屏幕的中心,并让“PlacePicker”构建屏幕?应该可以使用
生成器
,但我无法让它工作…@Cilenco:创建两个LatLng作为
新LatLng(中心-0.005,中心-0.005)
新LatLng(中心+0.005,中心+0.005)
,并将它们传递到LatLngBounds中,并在生成器中使用。因此,PlacePicker将围绕您指定的中心构建屏幕。将0.005增加到某个其他值,以获得围绕中心的更多面积。减小它以减小中心周围的面积。感谢您在我更改了
new LatLng(…)
语句中经纬度的顺序后为我工作。谢谢。。它确实帮助了很多。是否也可以只添加一个
LatLng
作为屏幕的中心,并让“PlacePicker”构建屏幕?应该可以使用
生成器
,但我无法让它工作…@Cilenco:创建两个LatLng作为
新LatLng(中心-0.005,中心-0.005)
新LatLng(中心+0.005,中心+0.005)
,并将它们传递到LatLngBounds中,并在生成器中使用。因此,PlacePicker将围绕您指定的中心构建屏幕。将0.005增加到某个其他值,以获得围绕中心的更多面积。减少它以减少中心周围的面积。感谢您在我更改
新LatLng(…)
语句中经纬度顺序后为我工作。