Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps Google Maps API V3-打开当前视图边界中附加到标记的所有信息窗口?_Google Maps_Google Maps Api 3 - Fatal编程技术网

Google maps Google Maps API V3-打开当前视图边界中附加到标记的所有信息窗口?

Google maps Google Maps API V3-打开当前视图边界中附加到标记的所有信息窗口?,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我的maps对象上有以下侦听器: myMapObject.addListener('bounds_changed', function(){ mySearchBoxObject.setBounds(myMapObject.getBounds()); if(this.getZoom() == 14){ for(var i = 0; i < customInfoWindows.length; i++){

我的maps对象上有以下侦听器:

    myMapObject.addListener('bounds_changed', function(){
        mySearchBoxObject.setBounds(myMapObject.getBounds());
        if(this.getZoom() == 14){
            for(var i = 0; i < customInfoWindows.length; i++){
                customInfoWindows[i].open(myMapObject, customMarkers[i]);
            }
        }
    });
myMapObject.addListener('bounds_changed',function(){
mySearchBoxObject.setBounds(myMapObject.getBounds());
if(this.getZoom()==14){
对于(var i=0;i
在缩放级别14时,我会自动打开所有绑定到我在地图上放置的自定义标记的信息窗口


有没有办法使用API提供的信息只打开当前视图中的信息窗口?例如,如果我的地图上有20个标记/信息窗口,并且在当前缩放视图中只能看到4个标记,我只想打开与这4个标记关联的4个信息窗口。

在打开信息窗口之前,检查标记是否在范围内:

myMapObject.addListener('bounds_changed', function(){
    mySearchBoxObject.setBounds(myMapObject.getBounds());
    if(this.getZoom() == 14){
        for(var i = 0; i < customInfoWindows.length; i++){
            // check if is in bounds
            if (myMapObject.getBounds().contains(customMarkers[i].getPosition()))
                customInfoWindows[i].open(myMapObject, customMarkers[i]);
        }
    }
});
myMapObject.addListener('bounds_changed',function(){
mySearchBoxObject.setBounds(myMapObject.getBounds());
if(this.getZoom()==14){
对于(var i=0;i
方法返回具有
。包含
方法的对象

包含(latLng:latLng | LatLngLiteral)

返回值:布尔值

如果给定lat/lng在此范围内,则返回true


很好,您有记录
contains()
方法的URL吗?已添加到答案中