我正在努力寻找一种方法来设置此地图上的信息窗口的样式。我尝试通过设置 suppressInfoWindows: true 来抑制信息窗口,但这似乎不起作用。任何想法将不胜感激。我在这里阅读了很多谷歌文档和很多其他帖子,但找不到解决方案。
<script>
var geocoder;
var map;
var marker;
var layers = [];
function initialize() {
geocoder = new google.maps.Geocoder ();
var latlng = new google.maps.LatLng (51.505288, -0.191544);
var myOptions = {
zoom: 15,
disableDefaultUI: true,
styles: [
{
stylers: [
]
},
{
featureType: "poi.park",
stylers: [
{ color: "#aecfae" },
{ saturation: 0 },
{ lightness: 0 },
{ visibility: "simplified" }
]
},
{
featureType: "landscape",
stylers: [
{ color: "#ffffff" },
{ saturation: 0 },
{ lightness: 0 },
{ visibility: "simplified" }
]
},
{
featureType: "road.highway",
elementType: "labels",
stylers: [
{ color: "transparent" },
{ visibility: "off" },
]
},
{
featureType: "water",
elementType: "geometry.fill",
stylers: [
{ color: "#a5bfdd" },
{ visibility: "on" },
]
},
{
featureType: "road",
elementType: "labels",
stylers: [
{ color: "transparent" },
{ visibility: "off" },
]
},
{
featureType: "road",
elementType: "geometry",
stylers: [
{ color: "#e0e0e0" },
{ saturation: 0 },
{ lightness: 0 },
{ visibility: "simplified" }
]
}],
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
marker = new google.maps.Marker({map:map});
layers[0] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/VicarageGate.kml', {preserveViewport: true});
for (var i = 0; i < layers.length; i++) {
layers[i].setMap(map);
}
layers[1] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/PrimarySchools-1.kml',
{preserveViewport: true});
layers[2] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/SecondarySchools-1.kml', {preserveViewport: true});
layers[3] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/Culture-6.kml', {preserveViewport: true});
layers[4] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/Hotels-2.kml', {preserveViewport: false});
layers[5] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/Shopping.kml', {preserveViewport: false});
layers[6] = new google.maps.KmlLayer('http://www.cid-dev.co.uk/vicarage-phase-2/kml/Restaurants.kml', {preserveViewport: false});
for (var i = 1; i < layers.length; i++) {
layers[i].setMap(null);
}
}
function codeAddress () {
var address = document.getElementById ("address").value;
geocoder.geocode ( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results [0].geometry.location);
marker.setPosition(results [0].geometry.location);
map.setZoom(15);
}
else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
function toggleLayer(i) {
if(layers[i].getMap() === null) {
layers[i].setMap(map);
}
else {
layers[i].setMap(null);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map_canvas" style="position:absolute; width:100%; height:100%; top:0px; left:0px; right:0px; bottom:0px; z-index:100; background-color:#000;"></div>