私はグーグルマップを使用していて、マーカーのクリックで開く情報ウィンドウはJavaScript関数を呼び出します。
この関数から呼び出さなければならない複数のパラメーターを持つ別の関数があります。
以下は私のコードです:
function createMarker(point,custid,streetadd,city,state,zip,address,phone,website,co) {
var infowindowHover,infowindowClick;
var hoverText = "<CENTER><B>" + co + "</B></CENTER>";
var markerMarkup = "<TABLE><TR><TD colspan='2'><B>";
markerMarkup = markerMarkup + co + "</B></TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + streetadd + "</TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + city + "," + state + " " + zip + "</TD></TR><TR><TD colspan='2'>";
markerMarkup = markerMarkup + phone + "</TD></TR><TR><TD colspan='2'>";
if(website.indexOf("http://")>0) {
markerMarkup = markerMarkup +"<a href=";
} else {
markerMarkup = markerMarkup +"<a href=http://";
}
markerMarkup = markerMarkup + website + " target=_blank>" + website + "</a></TD></TR><TR><TD>";
var funCall = custid + "," + streetadd + "," + city + "," + state + "," + zip + "," + address + "," + phone + "," + website + "," + co;
markerMarkup = markerMarkup + "<input type='button' class='button' value='see available styles' id='styles' onclick='setstyles("+ funCall +");'></input>";
//markerMarkup = markerMarkup + "<input type='button' class='button' value='see available styles' id='styles' onclick='setstyles("+ custid +");'></input>";
markerMarkup = markerMarkup + "</TD></TR></TABLE>";
var marker = new google.maps.Marker({
position: point,
map: map,
icon: image
});
google.maps.event.addListener(marker, "mouseover", function () {
if (infowindowHover) infowindowHover.close();
infowindowHover = new google.maps.InfoWindow({content: hoverText});
infowindowHover.open(map, marker);
});
google.maps.event.addListener(marker, "mouseout", function () {
if (infowindowHover) infowindowHover.close();
});
google.maps.event.addListener(marker, "click", function () {
if (infowindowClick) infowindowClick.close();
infowindowClick = new google.maps.InfoWindow({ content: markerMarkup });
infowindowClick.open(map, marker);
});
//google.maps.event.addListener(marker, "mouseout", function () {
// if (infowindowClick) infowindowClick.close();
//});
return marker;
}
この関数から呼び出したい2番目の関数は次のとおりです。
function setstyles(idcust,streetadd,city,state,zip,address,phone,website,co){
var msg= "This feature is available only to logged-in ";
alert(idcust);
<%if Session("ctype")="1" then %>
alert(msg + " non wholesalers.");
<%else %>
<%if Session("ctype")="0" then %>
var storestyles = 'storestyles.asp?id=' + idcust;
document.getElementById('storeaddresses').style.display = 'block';
<%else %>
alert(msg + "users.");
<% end if %>
<%end if %>
}
現在はできないパラメータをからcreateMarker()
に渡したい。setstyles()