我是這樣做的(如上圖),點了地圖會開另一網頁show地圖,把地址傳到show圖的頁面(showmap.aspx)
showmap.aspx 如下
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Qaddress = Server.UrlDecode(Request.QueryString("ADD"))
address.Value = Qaddress
ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "GetMap", "tranAddress(""" & Qaddress & """);", True)
End Sub
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
function tranAddress(address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, Radd);
}
function Radd(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var fenway = new google.maps.LatLng(results[0].geometry.location);
var mapOptions = {
center: fenway,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: document.getElementById("address").value
});
}
else { alert(status); }
}
</script>
<form id="form1" runat="server">
<input type="text" size="60" id="address" runat="server" readonly="readonly" />
<div name="map_canvas" id="map_canvas" style="width: 800px; height: 600px"></div>
</form>
給你參考