在样式化Google Maps API V3时如何更改或添加road.highway的文本颜色

问题描述 投票:0回答:1

我正在尝试为地图设置样式,但文本不可见http://joxi.ru/RmzoN4DFR00d82。我需要在上面显示白色文本。这是我正在尝试的方法,但是没有运气

     {
        "featureType": "road.highway",
        "elementType": "labels.text.fill",
        "stylers": [
          {
            "color": "#FFFFFF"
          }
       ]
     }

json google-maps styles
1个回答
0
投票

我建议您使用Google的Styling Wizard。要更改高速公路标签的文本颜色,您可以使用以下样式作为示例:

[
  {
    "featureType": "road.highway",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#a1a1a1"
      },
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.icon",
    "stylers": [
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.text",
    "stylers": [
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.text.stroke",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]

从我在屏幕快照中看到的结果来看,问题可能在于您正在向图标添加颜色,从而覆盖了其中的文本内容(无法设置样式)。因此,请确保按照上述代码避免这种情况。

希望这对您有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.