0
我想在asp.net按鈕點擊事件上運行這個JavaScript函數,但是當我點擊按鈕時map沒有被加載。在這裏是我的代碼。請幫助我。Google Map on JavaScript函數
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
//這是我的JavaScript函數
<script type="text/javascript">
var map;
var layerl0;
function initializes()
{
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(16.003575733881323, 81.298828125),
zoom: 5,
mapTypeId: google.maps.MapTypeId.HYBRID
});
layerl0 = new google.maps.FusionTablesLayer({
query: {
select: "'geometry'",
from: '4757916',
where: "Address='kerala'"
},
map: map
});
}
</script>
//這是asp.net代碼從上面我的意見覆制
<body>
<form id="form1" runat="server">
<div>
<div>
<div id="map-canvas" style="height: 421px"></div>
</div>
<asp:Button ID="Button1" OnClientClick="initializes()" runat="server" Text="Button" />
</div>
</form>
</body>
我假設按鈕導致發生回傳,從而從停止JS在客戶端的瀏覽器中運行。使用標準的html'button'或'input type = button'元素來代替'asp:Button'。如果您將它用於客戶端交互,這隻會令您頭疼 – BLSully 2012-08-02 13:09:43