您好我在谷歌地图上禁用Google infoWindow,您可以通过访问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();
}
正如您所看到的,后备是一个简单的标记,不显示和信息窗口,但方向确实如此。
答案 0 :(得分: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
}
});
答案 1 :(得分:1)
在图层的选项中使用suppressInfoWindows:true:
layer = new google.maps.FusionTablesLayer({
map: map,
heatmap: {
enabled: false
},
options: {
suppressInfoWindows:true
}
});
答案 2 :(得分:0)
使用duncan的修复我只是使用了clickable:false选项,它似乎可以解决问题,非常感谢你!
directionsDisplay = new google.maps.DirectionsRenderer({
markerOptions : {
visible: true,
clickable: false
}
});