1

我已经编写了与 2 个谷歌地图窗口(api 3 版本)同时平移的代码。我也希望能够同时缩放。我已经让它在 api2 中工作,但我没有让它在 ap3 版本的谷歌地图中工作。有没有人建议?提前致谢

当前代码的示例工作

var map;
var map2;
function load(x,y) {

var myOptions = {
  zoom: 7,
  center: new google.maps.LatLng(x,y),
  mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map"), myOptions);

var myOptions2 = {
  zoom: 7,
  center: new google.maps.LatLng(x,y),
  mapTypeId: google.maps.MapTypeId.SATELLITE
}
map2 = new google.maps.Map(document.getElementById("map2"), myOptions2);

        var map_moving = 0;
        var map2_moving = 0;

        var zoomLevel = map.getZoom();  

   google.maps.event.addListener(map, 'bounds_changed', function() {


                            map2_moving = true;
            if (map_moving == false) {
                map2.setCenter(map.getCenter(), map.getZoom());
                                    infowindow.setContent('Zoom: ' + zoomLevel);
            }
                            map_moving = false;
                            map2_moving = true;
});


  google.maps.event.addListener(map2, 'bounds_changed', function() {
                        map_moving = true;
            if (map2_moving == false) {
                        map.setCenter(map2.getCenter(), map2.getZoom());
                                    infowindow.setContent('Zoom: ' + zoomLevel);
            }
                            map_moving = true;
                            map2_moving = false;

});

var infowindow = new google.maps.InfoWindow(
{ 
size: new google.maps.Size(150,50)
});
}
  //]]>

问候巴斯

4

0 回答 0