限制矩形区域,Google Maps V2

时间:2014-01-15 14:57:41

标签: android google-maps

在我的应用程序中使用了Google Maps V2。 这是代码片段,它描述了地图片段。

<?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>

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

3 个答案:

答案 0 :(得分:1)

你可以so

0 <Hello>
1 <Hello>
2 <Hello>
3 <Hello>
4 <Hello>
5 <Hello>
6 <0Hello>
7 <00Hello>
8 <000Hello>
9 <0000Hello>
0 <>
1 <0>

答案 1 :(得分:0)

我在google maps API的文档页面中找到了这个,但我不知道这是不是你想要的:

private GoogleMap mMap;
// Create a LatLngBounds that includes Australia.
private LatLngBounds AUSTRALIA = new LatLngBounds(
  new LatLng(-44, 113), new LatLng(-10, 154));

// Set the camera to the greatest possible zoom level that includes the
// bounds
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(AUSTRALIA, 0));

答案 2 :(得分:0)

查看https://stackoverflow.com/a/48473495/6117565。对于任何矩形区域,您必须知道纬线和长角。多数民众赞成。