-1
我正在使用Google Maps API v3,並試圖在地圖上放置多個標記。多標記問題(Google Maps API v3)
這是我的代碼:
var map;
var geocoder;
var bulleInfo = null;
var marker = null;
var siteLatLng;
var globalAddress;
var globalLocation;
var globalFirstName;
var globalLastName;
function initialize()
{
var centerMap = new google.maps.LatLng(48, 1);
var myOptions = {
zoom: 4,
center: centerMap,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
geocoder = new google.maps.Geocoder();
bulleInfo = new google.maps.InfoWindow({
content: "loading..."
});
}
function codeAddress(profiles)
{
for(i=0; i < profiles.length; i++) {
globalLocation = profiles[i].location;
globalFirstName = profiles[i].first_name;
globalLastName = profiles[i].last_name;
geocoder.geocode({'address': globalLocation}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
globalAddress = results[0].geometry.location;
putMarkers();
}
else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
function putMarkers()
{
marker = new google.maps.Marker({
map: map,
position: globalAddress,
zIndex: i,
html: globalFirstName
});
google.maps.event.addListener(marker, 'click', function() {
bulleInfo.setContent(this.html);
bulleInfo.open(map, this);
});
}
的問題是,所有的指標都是一樣的(等於曲線的最後一個元素)!
出了什麼問題?
謝謝!
謝謝關懷!將看看你的例子! – 2010-11-28 01:46:44