gpt4 book ai didi

android - 限制矩形区域,Google Maps V2

转载 作者:行者123 更新时间:2023-11-30 03:09:57 25 4
gpt4 key购买 nike

在我的应用程序中使用了 Google Maps V2。这是描述 map fragment 的代码 fragment 。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

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

<ImageView
android:id="@+id/center_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@drawable/btn_centering"
android:clickable="true" />

</RelativeLayout>

如何限制用户可以导航的 map 矩形区域?我试着用 OnCameraChangeListener 来做这件事,但它看起来很难看而且不稳定。 (也许这是我的错)))

最佳答案

你能做到so :

// Create a LatLngBounds that includes the city of Adelaide in Australia.
final LatLngBounds ADELAIDE = new LatLngBounds(
new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));

// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);

关于android - 限制矩形区域,Google Maps V2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21140754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com