Google maps api 3 不使用边界扩展地图边界的正确方法。扩展(点)
我正在使用贴图边界显示位于当前视口中的标记。缩放或平移时,将重新计算边界,并重新绘制位于这些边界内的标记,从而有效地隐藏视口中未包含的任何标记。 我想这样做,使标记稍微画出当前视口,但这将涉及从所有方面平均延伸边界,而不是使用bounds.extend(point)。这可能吗Google maps api 3 不使用边界扩展地图边界的正确方法。扩展(点),google-maps-api-3,extend,bounds,Google Maps Api 3,Extend,Bounds,我正在使用贴图边界显示位于当前视口中的标记。缩放或平移时,将重新计算边界,并重新绘制位于这些边界内的标记,从而有效地隐藏视口中未包含的任何标记。 我想这样做,使标记稍微画出当前视口,但这将涉及从所有方面平均延伸边界,而不是使用bounds.extend(point)。这可能吗 //I would like to extend this value in order to draw features that are slightly off the viewport
//I would like to extend this value in order to draw features that are slightly off the viewport
var bounds = map.getBounds()
//This is how I am currently extending the bounds, it works but I am unsure if it is the correct way.
bounds.b.b = bounds.b.b - 0.5
bounds.b.f = bounds.b.f + 0.5
bounds.f.b = bounds.f.b - 0.5
bounds.f.f = bounds.f.f + 0.5
//Determining whether the feature lies within the current viewport
var result = bounds.contains(Featurecenter)
center = null
//If the feature lies within the viewport
if (result) {
Feature.setMap(map) //Making the feature visible on the map
}
b
、f
等未记录的属性,而是使用记录的方法,例如getNorthEast()
、getSouthWest()
然后lat()
和lng()
LatLngBounds
对象具有一个必须用于实现所需目标的属性你试过什么?您发布的代码没有显示任何扩展边界的尝试。我没有发现任何可以尝试的东西,因为所有示例都说将边界扩展到某个坐标,这对我来说是行不通的。我唯一的想法是通过改变坐标手动增加边界,但这似乎不是最好的解决方案。我添加了我尝试过的有效方法,但我不确定这是否是执行此过程的正确方法。