我需要从这个数组中获取数据:
var array = [['USA','USA Office'],['Canada','Canada Office']]
并使用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);
});
});
}
});
答案 0 :(得分:0)