0
我需要從這個數組中獲取數據:信息窗口添加到每個標記(的onclick標記)
VAR陣列= [ 'USA', 'USA辦公室'],[ '加拿大', '加拿大辦事處'] ]
並使用infowindow創建每個國家標記。
現在我有這個(僅國家):
jQuery(document).ready(function() {
var map;
var elevator;
var myOptions = {
zoom: 3,
center: new google.maps.LatLng(54.236107, -4.548056),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(jQuery('#map_canvas')[0], myOptions);
var addresses = ['Canada', 'Germany', 'France','USA','Ireland'];
for (var x = 0; x < addresses.length; x++) {
jQuery.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='+addresses[x]+'&sensor=false', null, function (data) {
var p = data.results[0].geometry.location;
var latlng = new google.maps.LatLng(p.lat, p.lng);
var infowindow = new google.maps.InfoWindow({
content: 'addresses'
});
var marker = new google.maps.Marker({
position: latlng,
map: map
});
google.maps.event.addListener(marker, 'click', function() {
alert("Marker clicked");
infowindow.open(map,marker);
});
});
}
});