Google地图停放边框

时间:2017-10-14 14:40:24

标签: google-maps

是否可以在Google地图上显示公园边框?我已经能够使用以下样式将公园设为紫色:

{
    featureType: 'poi.park',
    elementType: 'geometry.fill',
    stylers: [{color: '#aa44aa'}]
}

enter image description here

并尝试了以下方法来启用边框,但它无效。

{
    featureType: 'poi.park',
    elementType: 'geometry.stroke',
    stylers: [{color: '#000000'}]
}

完整的jsfiddle here

Google地图的样式参考为here

完整代码:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Parks</title>
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      // This example creates circles on the map, representing populations in North
      // America.


      function initMap() {
        // Create the map.
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 11,
          center: {lat: 37.180240, lng: -121.434949},

          styles: [
          {
              featureType: 'poi.park',
              elementType: 'geometry.fill',
              stylers: [{color: '#aa44aa'}]
          }/*,
          {
                featureType: 'poi.park',
                elementType: 'geometry.stroke',
                stylers: [{color: '#000000'}]
          },*/
          ]
        });
        }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=&callback=initMap">
    </script>
  </body>
</html>

1 个答案:

答案 0 :(得分:2)

目前,API不会公开功能边框。谷歌问题跟踪器中有一个非常古老的功能请求,但是,看起来Google没有为此任务设置高优先级。

https://issuetracker.google.com/issues/35816953

随意在功能请求中添加星标以添加投票并订阅通知。