本文介绍了在用户控件中调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在用户控制页面中显示了带有地理编码的google地图.
地图未显示地址-
请参阅以下代码:
I am showing a google map with geo coding in my usercontrol page.
The map is not displaying the address -
see the following code:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ChangeLocation.ascx.cs" Inherits="onlocal.UserControls.ChangeLocation" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<link href="../CSS/common.css" rel="stylesheet" type="text/css" />
<script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAvpd8mjNgroIYlldQP4fM-hREifw3z0CLY54LRc8ZC14v-wuusRQrD9AaPPOw_rxAgdi_bPu9S-lQxg" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
geocoder = new GClientGeocoder();
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
}
alert('test link');
initialize();
alert('test link2');
</script>
<cc1:ModalPopupExtender ID="ModalPopupChangeLocation" BehaviorID="ModalPopupChangeLocation"
runat="server" BackgroundCssClass="modalBackground" TargetControlID="lnkDummy"
PopupControlID="pnlModalPopupChangeLocation" CancelControlID="imgBtnCancel">
</cc1:ModalPopupExtender>
<asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
<asp:Panel ID="pnlModalPopupchangelocation" runat="server" Style="display: none;">
<asp:UpdatePanel ID="updatechangelocation" runat="server">
<ContentTemplate>
<div style="width: 430px; height: 230px; overflow: hidden;" class="content" >
<div class="blueNavPopUp" style="width: 430px;">
<div class="blueNavTextPopUp">
<asp:Label ID="lblTitle" runat="server" class="whiteTabText">Change
Location</asp:Label></b></div>
<div class="collaspebtmPopUp">
<asp:ImageButton ID="imgBtnCancel" runat="server" ImageUrl="~/images/CloesImg.gif" OnClientClick="javascript:$find('ModalPopupChangeLocation').hide(); return false;"
alt="" /></div>
</div>
<p>
<input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" />
<input type="submit" value="Go!" onclick="initialize(); return false;" />
</p>
<div id="map_canvas" style="width: 500px; height: 300px; background-color:Aqua;"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel><p>
</p>
推荐答案
这篇关于在用户控件中调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!