谷歌地图api 3同时平移和缩放

时间:2013-01-09 15:35:19

标签: maps zooming panning

我已经制作了与2个谷歌地图窗口(api 3版本)同时平移的代码。我想也可以同时缩放。我已经使它在api2中工作但我不能在ap3版本的谷歌地图中使用它。有人建议吗?提前致谢

example working of current code

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)
});
}
  //]]>

问候 BAS

0 个答案:

没有答案