Google地图 - 标记列表取决于缩放级别

时间:2015-06-16 15:22:18

标签: javascript google-maps google-maps-api-3

我在我的gmaps中有一个标记列表:

document.getElementById('sidebar').innerHTML +=
            '<li class="list-sidebar '+ type +'"><a href="javascript:myclick(' +
            i + ')"  >' + name + '</a></li>';

我想列出这样的标记列表:https://www.mapbox.com/mapbox.js/example/v1.0.0/listing-markers/

如果您放大或缩小,标记在地图和列表中是否可见。我知道,它的 inBounds 但是不知道怎么回事。

1 个答案:

答案 0 :(得分:2)

仔细查看该页面中的javascript,重要的一行是:

bounds = map.getBounds();

if (bounds.contains(marker.getLatLng())) {
    ...
}

inBounds只是他们用来输出这些标记列表的数组。标题。