Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.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

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
Javascript 谷歌地图v3同步拖动_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 谷歌地图v3同步拖动

Javascript 谷歌地图v3同步拖动,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,当用户拖动两张谷歌地图时,我正在尝试同步屏幕上两张谷歌地图的移动 目前我正在收听center\u changed事件。但是,只有在完成拖动后才会调用,因此第二个贴图仅在拖动之后移动,而不是在拖动过程中移动 我当前的代码如下所示 var mapOptions = { center: new google.maps.LatLng(52.287373, -1.548609), zoom: 12, // streetViewControl: false

当用户拖动两张谷歌地图时,我正在尝试同步屏幕上两张谷歌地图的移动

目前我正在收听
center\u changed
事件。但是,只有在完成拖动后才会调用,因此第二个贴图仅在拖动之后移动,而不是在拖动过程中移动

我当前的代码如下所示

    var mapOptions = {
      center: new google.maps.LatLng(52.287373, -1.548609),
      zoom: 12,
      // streetViewControl: false
      disableDefaultUI: true,
      // draggable: false,
      // disableDoubleClickZoom: false
    };
    mapOptions["styles"] = dayStyle;
    map = new google.maps.Map(document.getElementById("map-canvas"),
        mapOptions);


    backgroundMap = new google.maps.Map(document.getElementById("background-map"),
        mapOptions);

    google.maps.event.addListener(map, 'center_changed', function() {
        // Set backgroundMap to match actual map
        backgroundMap.panTo(map.getCenter());
    });

    google.maps.event.addListener(map, 'zoom_changed', function() {
        // Set backgroundMap zoom to be further out than actual map
        backgroundMap.setZoom((map.getZoom()-2 >= 1) ? map.getZoom()-2 : 1);
    });

但我真的很想创造出同样的效果。我已经尝试使用
bindTo
方法将背景贴图链接到前景贴图。但是,这也只会在拖动完成后更新背景地图。

拖动事件是您想要的,但是将其与更改的
中心一起使用,因为使用键盘箭头进行平移不会触发拖动事件。

我的代码似乎在桌面环境中工作

然而,maps JS API限制了移动环境中的it回调速率(我只能假设这是出于性能原因),因此每次拖动只能调用
center\u changed
一次。不同于桌面上,它的调用频率要高得多