iT邦幫忙

0

ASP.NET + Google Map

u33963 2011-09-25 00:35:0210066 瀏覽
  • 分享至 

  • xImage

各位大大你好:
我想請問你們,

  1. ASP.NET 可不可以跟GOOGLE MAP 結合?
  2. 我的網頁是用ASP.NET 做,我有兩個下拉式選單,按下搜尋鈕後,會顯示所要找尋的資料,而
    且這些資料會跟著GOOGLE MAP 一起顯示出來,請問要如何把它們兜在一塊或是要怎麼做呢??
    感謝各位 拜託!!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

10
sonia
iT邦新手 2 級 ‧ 2011-09-26 10:13:38
最佳解答


我是這樣做的(如上圖),點了地圖會開另一網頁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>

給你參考

我要發表回答

立即登入回答