GeoCodingサービスを使用して、複数のマーカーとinfoWindowsを追加するコードを作成しました。APIv3ドキュメントからメソッドをコピーしました。私のスクリプトは、ASP.Net Webサービスからアドレス情報を取得し、それらを非表示のdiv要素に書き込みます。
function codeAddress(address)
{
//Get the location information from address
geocoder.geocode( { 'address': address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK)
{
//Add a google marker onto the given address
var marker = new google.maps.Marker({
map: map,
animation: google.maps.Animation.DROP,
position: results[0].geometry.location
});
//Prepare a infoWindow to display complete address
var faddress = "<h4>Office Address:</h4><span>" + address + "</span>";
var infowindow = new google.maps.InfoWindow({content: faddress});
//Opening information window on mouseover event of marker
google.maps.event.addListener(marker, 'mouseover', function(){
infowindow.open(map, marker);
});
//closing the info window when mouse is moved out of marker
google.maps.event.addListener(marker, 'mouseout', function(){
infowindow.close();
});
}
});
}
次のコードは、非表示のdiv要素からアドレスを読み取り、InfoWindowsとともにマーカーを追加します。このコードは、Internet Explorer 7.0/8.0で完全に機能します。
//Populate the result onto div element
$.each(arr,function(index, item){
$(".result").append("<div class='block'>" + item + "</div>");
});
//Loop through the div element and add marker to map
$(".block").each(function(){
codeAddress($(this).text());
})
しかし、Firefox 6.0 / IE 9.0で開いたときに、同じコードが機能しません。
GeoCodingサービスは、同じ呼び出しに対してZERO_RESULTSを返します。同じアドレスでメソッドを5回呼び出すと、マーカーを追加できます。
geoCodingサービスに新しいブラウザで問題があるかどうかについて何か考えはありますか?
前もって感謝します...
Sudhir