Har*_*sha 6 maps android google-maps android-theme
我已经在我的Android应用程序中实现了Google地图,一切看起来都很干净,直到几天.以前,地图看起来像下图
现在,地图的外观与下图相似
我没有在实现中更改或更新任何内容,但地图上有暗线,这使得难以阅读这些地方.
任何帮助表示赞赏.谢谢
注意:我已从Google下载图片以供参考,请忽略xml布局更改.
小智 6
首先去官方即https://mapstyle.withgoogle.com/ 并获取您的样式值的 json 并复制到资源中的原始文件夹
然后像这样应用在你的 onMapready() 上
MapStyleOptions mapStyleOptions = MapStyleOptions.loadRawResourceStyle(this, R.raw.style_json);
mGoogleMap.setMapStyle(mapStyleOptions);
Run Code Online (Sandbox Code Playgroud)
我想您可能添加了地图主题,如果添加了,请删除或更改主题
//Custom Theme
MapStyleOptions style = MapStyleOptions.loadRawResourceStyle(this.context, R.raw.my_map_style);
map.setMapStyle(style);
Run Code Online (Sandbox Code Playgroud)
更改主题请在这里参考。
从这里创建主题。
重写样式 json 文件。尝试改变不同的颜色代码。
代码
MapStyleOptions mapStyleOptions = MapStyleOptions.loadRawResourceStyle(activity,
R.raw.map_style);
googleMap.setMapStyle(mapStyleOptions);
Run Code Online (Sandbox Code Playgroud)
原始/map_style.json 文件
[
{
"featureType": "administrative",
"elementType": "all",
"stylers": [
{
"saturation": "40"
},
{
"lightness": "5"
}
]
},
{
"featureType": "administrative",
"elementType": "geometry.stroke",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "administrative",
"elementType": "labels.text",
"stylers": [
{
"hue": "#ff0000"
},
{
"visibility": "on"
}
]
},
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#000000"
}
]
},
{
"featureType": "administrative.locality",
"elementType": "labels.text",
"stylers": [
{
"visibility": "simplified"
},
{
"color": "#cb561a"
}
]
},
{
"featureType": "administrative.locality",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#858585"
}
]
},
{
"featureType": "administrative.neighborhood",
"elementType": "geometry.stroke",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "administrative.neighborhood",
"elementType": "labels.text.fill",
"stylers": [
{
"visibility": "on"
},
{
"color": "#858585"
}
]
},
{
"featureType": "administrative.neighborhood",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "on"
},
{
"color": "#00467f"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "all",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#a8a8a8"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"visibility": "on"
},
{
"hue": "#ffc800"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "all",
"stylers": [
{
"hue": "#ffc800"
},
{
"saturation": "25"
},
{
"lightness": "42"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry",
"stylers": [
{
"visibility": "on"
},
{
"lightness": "8"
},
{
"gamma": "0.75"
},
{
"saturation": "-6"
},
{
"hue": "#ffc600"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry.stroke",
"stylers": [
{
"visibility": "on"
},
{
"weight": "1.77"
}
]
},
{
"featureType": "poi",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#aeaeae"
},
{
"visibility": "on"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "on"
},
{
"color": "#8bd188"
},
{
"lightness": "41"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#949595"
},
{
"visibility": "on"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{
"visibility": "on"
},
{
"hue": "#ff0000"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#686868"
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [
{
"weight": "1.03"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "transit",
"elementType": "labels",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#b3e9ff"
},
{
"visibility": "on"
}
]
},
{
"featureType": "water",
"elementType": "geometry.fill",
"stylers": [
{
"saturation": "-35"
},
{
"color": "#b6e0f3"
}
]
},
{
"featureType": "water",
"elementType": "labels.icon",
"stylers": [
{
"color": "#86c1ea"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
534 次 |
| 最近记录: |