0

嗨,您是否在我的谷歌地图上禁用了谷歌信息窗口,正如您通过访问http://harpers.everythingcreative.co.uk/contact所看到的那样,信息窗口看起来很奇怪并且显示的地址不正确。

    // ---------- Geolocation ----------    
function fallback() {
            var myOptions = {
            center: new google.maps.LatLng(51.43255949795703, -0.461750328540802),
            zoom: 14,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            };

            var map = new google.maps.Map(document.getElementById("Map_Canvas"),
            myOptions);

            var markerPos = new google.maps.LatLng(51.43255949795703, -0.461750328540802);
            var marker = new google.maps.Marker({
            position: markerPos,
            map: map,
            title: "The Harpers Hairdressing"
            });
            }

   function initGeolocation() 
    { 
           if(navigator.geolocation) 
            { 
              // Call getCurrentPosition with success and failure callbacks 
              navigator.geolocation.getCurrentPosition( success, fail ); 
            } 
        else 
            { 
              fallback()
               } 
    } 
    var directionDisplay; 
    var directionsService = new google.maps.DirectionsService(); 
    var map; 
    function success(position) { 
      directionsDisplay = new google.maps.DirectionsRenderer(); 
      coords = new google.maps.LatLng(position.coords.latitude, 
position.coords.longitude); 
      var myOptions = { 
        zoom:12, 
        mapTypeId: google.maps.MapTypeId.ROADMAP, 
        center: coords 
      } 
      map = new google.maps.Map(document.getElementById("Map_Canvas"), 
myOptions); 
      directionsDisplay.setMap(map);
      calcRoute();
    } 
    function calcRoute() { 
      var start = coords; 
      var end = new google.maps.LatLng(51.43255949795703, -0.461750328540802); 
      var request = { 
        origin:start, 
        destination: "3 Fir Tree Place, Church Road, Ashford, Middlesex, TW15 2PH",
        travelMode: google.maps.TravelMode.DRIVING,
      }; 
      directionsService.route(request, function(result, status) { 
        if (status == google.maps.DirectionsStatus.OK) { 
          directionsDisplay.setDirections(result); 
        } 
      }); 
    } 
        function fail() 
        { 

           fallback();

} 

如您所见,后备是一个简单的标记,它不显示和信息窗口,但方向显示。

4

3 回答 3

1

在图层选项中使用 suppressInfoWindows:true :

layer = new google.maps.FusionTablesLayer({
        map: map,
        heatmap: {
            enabled: false
        },
        options: {
            suppressInfoWindows:true
        }
    });
于 2014-03-12T02:51:51.347 回答
1

在您的 DirectionsRenderer 对象上,您可以传入一个 DirectionsRendererOptions 选项结构。其中有一个 markerOptions 值,您应该能够使用它来取消标记与地图的关联。

像这样的东西可能会起作用:

directionsDisplay = new google.maps.DirectionsRenderer({
  markerOptions : {
        map: null,  //  you probably would only need 1 or the other of these two values
        visible: false
  }
}); 
于 2012-09-18T10:43:01.170 回答
0

使用邓肯的修复,我只使用了 clickable:false 选项,它似乎可以解决问题,非常感谢!

    directionsDisplay = new google.maps.DirectionsRenderer({
        markerOptions : {
            visible: true,
            clickable: false
        }
  }); 
于 2012-09-18T18:11:41.450 回答