我想从 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/