我正在创建一个带有Marker和InfoWindow的地图。除了InfoWindow之外,一切似乎都在起作用。我在Firebug中也没有看到任何错误。
这是我的JavaScript:
var myOptions = {
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map;
var geocoder;
var marker;
var infowindow;
function initialize() {
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': '327 5th St, West Palm Beach, FL 33401-3995'}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
myOptions.center = results[0].geometry.location;
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title: 'Middle East Bakery & Grocery'
});
infowindow = new google.maps.InfoWindow({
title: '<strong>Middle East Bakery & Grocery</strong><br />327 5th St<br />West Palm Beach, FL 33401-3995'
});
infowindow.open(map, marker);
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
答案 0 :(得分:0)
这一位:
infowindow = new google.maps.InfoWindow({
title: '<strong>Middle East Bakery & Grocery</strong><br />327 5th St<br />West Palm Beach, FL 33401-3995'
});
应该是:
infowindow = new google.maps.InfoWindow({
content: '<strong>Middle East Bakery & Grocery</strong><br />327 5th St<br />West Palm Beach, FL 33401-3995'
});
我为配置设置了错误的参数。 title
应该是content
。