gpt4 book ai didi

android - 样式化谷歌地图

转载 作者:行者123 更新时间:2023-11-29 14:26:35 28 4
gpt4 key购买 nike

我想创建一个使用谷歌地图的安卓应用。我用了Google Maps APIs Styling Wizard并创建了 json 文件。我必须在我的应用程序代码 (android studio) 中进行哪些更改才能应用更改?

最佳答案

map 准备就绪后,您可以在 OnMapReady 中应用样式更改

@Override
public void onMapReady(GoogleMap map) {
mMap = map;
setMapStyle();
}

private void setMapStyle() {
MapStyleOptions style = new MapStyleOptions("[" +
" {" +
" \"featureType\":\"poi.business\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }," +
" {" +
" \"featureType\":\"transit\"," +
" \"elementType\":\"all\"," +
" \"stylers\":[" +
" {" +
" \"visibility\":\"off\"" +
" }" +
" ]" +
" }" +
"]");

mMap.setMapStyle(style);
}

检查这些链接:MapStyleOptions , GoogleSamples

关于android - 样式化谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40139449/

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