android - 从 google map api v2 中删除默认对象

标签 android google-maps android-layout google-maps-markers google-maps-android-api-2

我想从 Google map 中删除所有默认对象或地点。我希望知道这是更容易还是在覆盖层上构建更容易。我想要一张谷歌支持的空白 map 。我会随时添加我需要的地方或对象,这可以吗? maps.clear() 没有添加任何帮助,我想要一些 onCreate() 方法或 onStart() 方法来删​​除所有地方,并有一张空白 map ,没有地方,只有道路和建筑物。

public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mapReady = true;
    Double latitude = location.getLatitude();
    Double longitude = location.getLongitude();
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mMap.setMyLocationEnabled(true);
    // Add a marker in Sydney and move the camera
    //LatLng sydney = new LatLng(-34, 151);
    LatLng currentPosition = new LatLng(latitude,longitude);
    mMap.addMarker(new MarkerOptions().position(currentPosition).title("Current Location"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(currentPosition));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
    mMap.setMapType();
    loadNearByPlaces(latitude,longitude);
}

这是我使用的起始代码。如何修改它并使其满足我的需要?

最佳答案

如果您应用自定义样式,您可以隐藏地点和 POI 的默认图标并实现您的目标。

看看教程:

https://developers.google.com/maps/documentation/android-api/styling

样式向导位于:

https://mapstyle.withgoogle.com/

例如,要隐藏 map 上的所有商家,您可以应用以下样式

[
  {
    "featureType": "poi.business",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]

关于android - 从 google map api v2 中删除默认对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41913001/

相关文章:

Android Studio Crashes on Launch、El Capitan、freetype 相关、fontmanager 错误?

javascript - 在 map 上显示多个标记时,如何在单击标记时只打开一个信息窗口?

android - 如何在一个地方定义按钮背景并在整个应用程序中使用?

使用 gridview 和 RecyclerView 滚动的 android 布局

启动器图标上的 Android 通知

android - 在 TextView 上选择文本(android 2.2)

javascript - Google 地理编码仅在没有 API key 的情况下运行

javascript - 在谷歌地图中拖放自定义图标集

android - 我怎样才能在我的应用程序中实现 longclickable

java - 当我触摸屏幕时 Android 应用程序崩溃 - nullPointerException