创建带自定义主题的GoogleMap的实用类 – ThemedGoogleMap

ThemedGoogleMap

创建带自定义主题的GoogleMap的实用类。

创建你自己的主题:

GoogleMapStyler googleMapStyler = new GoogleMapStyler.Builder()
                        .setMainGeometryColor(ContextCompat.getColor(MainActivity.this, R.color.maingeometrycolor))
                        .setAllPlaceTextStrokeAlpha(-80)
                        .setAllPlaceTextColor(ContextCompat.getColor(MainActivity.this, R.color.adminstartivelabel))
                        .setAllMainTownTextColor(ContextCompat.getColor(MainActivity.this, R.color.administativelocality))
                        .setAllPoiTextColor(ContextCompat.getColor(MainActivity.this, R.color.poitext))
                        .setAllPoiParkBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.poiparkbackground))
                        .setAllPoiParkTextColor(ContextCompat.getColor(MainActivity.this, R.color.poilabel))
                        .setAllRoadBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.roadbackground))
                        .setAllRoadTextColor(ContextCompat.getColor(MainActivity.this, R.color.roadlabel))
                        .setAllRoadArterialBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.roadarterialbackground))
                        .setAllRoadArterialStrokeColor(ContextCompat.getColor(MainActivity.this, R.color.roadarterialstroke))
                        .setAllRoadHighwayBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.roadhighway))
                        .setAllRoadHighwayStrokeColor(ContextCompat.getColor(MainActivity.this, R.color.roadhighwaystroke))
                        .setAllRoadHighwayTextColor(ContextCompat.getColor(MainActivity.this, R.color.roadhighwaylabel))
                        .setAllRoadLocalBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.roadlocal))
                        .setAllRoadLocalStrokeColor(ContextCompat.getColor(MainActivity.this, R.color.roadlocalstroke))
                        .setAllTransitStationTextColor(ContextCompat.getColor(MainActivity.this, R.color.transitstationtext))
                        .setAllTransitBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.transit))
                        .setAllWaterTextColor(ContextCompat.getColor(MainActivity.this, R.color.waterlabel))
                        .setAllWaterBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.water))
                        .setAllWaterTextStrokeAlpha(-20)
                        .build();

对谷歌地图应用生成的样式

googleMap.setMapStyle(googleMapStyler.getMapStyleOptions());

转载注明原文:创建带自定义主题的GoogleMap的实用类 – ThemedGoogleMap - 代码日志