简体   繁体   English

缩小时,Google地图不显示我的折线

[英]Google Maps does not display my Polyline when zoomed out

As it seems to me, google made some changes to the way their google maps API displays Polylines. 在我看来,谷歌对其Google Maps API显示折线的方式进行了一些更改。 Up until last time I checked (3 months ago) Polylines would always be visible at all zoom-levels. 直到上次我检查(3个月前)时,折线在所有缩放级别都始终可见。 When fully zoomed out, the polyline would just be a small dot on he map. 完全缩小后,折线将只是地图上的一个小点。

Now, using the same code (basically just the example code offered by google) when I zoom out, the polyline will disappear. 现在,缩小时使用相同的代码(基本上只是google提供的示例代码),折线将消失。 This only happens, in case the waypoints of the polyline a very close together. 仅在折线的航路点非常靠近的情况下才会发生这种情况。

Example: A Polyline confined to some streets in a small town will not be visible, when zoom out completly. 示例:完全缩小时,将看不到局限于小镇某些街道的折线。 A Polyline which connects to points with a distance of 1000 miles will always be visible. 连接到距离为1000英里的点的折线始终可见。

How can I get the short Polyline to be displayed at all zoom-levels, even if it will just be a small dot? 我怎么能在所有缩放级别上显示短的折线,即使它只是一个小点?

Example here: 这里的例子:

https://plnkr.co/edit/v7FksNUxlpm1f6ag0iQs?p=preview https://plnkr.co/edit/v7FksNUxlpm1f6ag0iQs?p=preview

just zoom out, at some point the polyline will disappear, which I do not want. 只是缩小,在某些时候折线会消失,这是我不想要的。

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">    
    <meta charset="utf-8">
    <title>Simple Polylines</title>
    <style>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #map {
        height: 100%;
      }
    </style>
  </head>
  <body>
<div id="map"></div>
<script>


function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 18,
    center: {lat: 37.772, lng: -122.214},
    mapTypeId: google.maps.MapTypeId.TERRAIN
  });

  var flightPlanCoordinates = [
{lat: 37.772, lng: -122.214},
{lat: 37.771, lng: -122.215},
{lat: 37.770, lng: -122.216},
{lat: 37.760, lng: -122.218}
  ];
  var flightPath = new google.maps.Polyline({
    path: flightPlanCoordinates,
    geodesic: true,
    strokeColor: '#FF0000',
    strokeOpacity: 1.0,
    strokeWeight: 40
  });

  flightPath.setMap(map);
}

</script>
<script async defer
    src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script> 
  </body>
</html>

Call zoomIn or zoomOut on another thread loop. 在另一个线程循环上调用zoomIn或zoomOut。 (ex. setTimeout(event) (例如setTimeout(event)

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

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