1

誰かがこれで私を助けてくれることを願っています.ズームと中央揃えで2つの方向点を表示しようとしているので、すべての地図ではなく2つの点だけを表示できます! ズームが効かないようです。

ここに私のコードがあります

       var map;
        function initialize(){                  
                  var mapOptions = {
                  zoom: 14,
                  disableDefaultUI: true,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);


                var request = {
                        origin:"Mexico",
                        destination:"Montreal",
                        travelMode: google.maps.TravelMode.DRIVING
                };

                var directionsService = new google.maps.DirectionsService();
                var directionsDisplay = new google.maps.DirectionsRenderer();

                // Indicamos dónde esta el mapa para renderizarnos
                directionsDisplay.setMap(map);

                directionsService.route(request, function(result, status) {
                    if (status == google.maps.DirectionsStatus.OK) {
                      directionsDisplay.setDirections(result);
                    }
                  }); 
        }

        google.maps.event.addDomListener(window, 'load', initialize);

前もって感謝します

4

1 に答える 1

0

問題の変更を修正するには:

disableDefaultUI: true, 

disableDefaultUI: false,

[Google Maps API] から: https://developers.google.com/maps/documentation/javascript/controls#DisablingDefaults

代わりに、API のデフォルトの UI 設定をオフにすることができます。これを行うには、マップの disableDefaultUI プロパティ (マップ オプション オブジェクト内) を true に設定します。このプロパティは、Google Maps API からの自動 UI 動作を無効にします。

それでも UI 要素を無効にしたい場合は、おそらく個別に行う必要があります。

于 2013-03-22T18:59:26.533 に答える