Google Map文本样式在Android上的外观与在样式向导中不同

时间:2018-12-20 23:44:52

标签: android google-maps google-maps-android-api-2 google-maps-styled

我在样式向导(https://mapstyle.withgoogle.com/)中创建了Google Maps样式,但在Android应用中生成的结果与向导中显示的结果不同。文本标签看起来很笨重,好像重量很大。

这是从样式向导复制到我的应用程序中的json:

[
  {
    "elementType": "labels.text",
    "stylers": [
      {
        "color": "#ffffff"
      },
      {
        "visibility": "off"
      },
      {
        "weight": 0.1
      }
    ]
  },
  {
   "featureType": "landscape",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#474644"
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#626061"
      }
    ]
  },
  {
    "featureType": "poi.park",
   "elementType": "geometry",
    "stylers": [
      {
        "color": "#626061"
      }
    ]
  },
  {
    "featureType": "poi.park",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#666666"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "on"
      }
    ]
  }
]

以下是地图在样式向导中的显示方式: Google Styling Wizard

,这是我的Android应用程序中的结果: Android styled map

1 个答案:

答案 0 :(得分:0)

我能够通过在Android应用中将样式器添加到json中来解决此问题,该设置将所有标签文本填充的可见性设置为off

{
     "elementType": "labels.text.fill",
     "stylers": [
       {
         "visibility": "off"
        }
     ]
}