简体   繁体   English

Google 地图 - 禁用地图图块并仅显示多边形形状

[英]Google Maps - Disable map tiles and show only polygon shapes

Working with Google Maps V3 Api.使用 Google Maps V3 Api。 This is a strange request, but i wondered if its possible to draw polygon shapes on the map canvas using LAT and LONG, but disable/hide the the map tiles within the canvas.这是一个奇怪的请求,但我想知道是否可以使用 LAT 和 LONG 在地图画布上绘制多边形形状,但禁用/隐藏画布内的地图图块。 So in short, id like to show JUST the shapes that are drawn on the map.简而言之,id 喜欢只显示在地图上绘制的形状。

As per google maps docs you can do this when you initialize your map:根据谷歌地图文档,您可以在初始化地图时执行此操作:

  var map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 40.674, lng: -73.945},
          zoom: 12,
          styles: [
            {elementType: 'all', stylers: [{visibility: 'off'}]},
          ]
        });

This applies a custom style that hides everything on the map.这将应用隐藏地图上所有内容的自定义样式。 You could then apply a style to your polygons to make them appear.然后,您可以对多边形应用样式以使其出现。

https://developers.google.com/maps/documentation/javascript/styling https://developers.google.com/maps/documentation/javascript/styling

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM