1

文档显示 - http://google-maps-utility-library-v3.googlecode.com/svn/tags/keydragzoom/1.0/docs/examples.html

     function init(){
      var myOptions = { 
        zoom: 13, 
        center: new google.maps.LatLng(49.2903, -123.1294), 
        mapTypeId: google.maps.MapTypeId.ROADMAP 
       };
      var map = new google.maps.Map(document.getElementById("map"), myOptions); 
      map.enableKeyDragZoom({
            boxStyle: {
              border: "thick dashed black",
              backgroundColor: "red",
              opacity: 0.5
            },
            paneStyle: {
              backgroundColor: "gray",
              opacity: 0.2
            }
      });
    }

但是因为我使用的是gmap3,所以我不确定如何实现?这是我初始化地图的代码

     $('#dispatcher').gmap3(
      {action: 'init',
        options:{
          center:[53.9783997, -1.5666347],
          zoom:6,
          mapTypeId: google.maps.MapTypeId.MAP,
          mapTypeControl: true,
          mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
          },
          navigationControl: true,
          scrollwheel: true,
          streetViewControl: true
        }
      }

有任何想法吗?干杯

4

2 回答 2

2

试试这个:

$('#dispatcher').gmap3({action:'get'}).enableKeyDragZoom({
            boxStyle: {
              border: "thick dashed black",
              backgroundColor: "red",
              opacity: 0.5
            },
            paneStyle: {
              backgroundColor: "gray",
              opacity: 0.2
            }
      });

.gmap3({action:'get'})返回google.maps.Map对象。因此,您可以对其执行任何操作,该google.maps.Map对象可以执行,包括enableKeyDragZoom操作。

于 2012-06-13T11:18:54.317 回答
0

是的,或者您也可以使用“init”中的回调函数,其中包括地图:

    callback: function(map){
       map.enableKeyDragZoom({
        boxStyle: {
          border: "thick dashed black",
          backgroundColor: "red",
          opacity: 0.5
        },
        paneStyle: {
          backgroundColor: "gray",
          opacity: 0.2
                }
        });
    }
于 2012-06-19T09:27:00.727 回答