在地图上显示位置的地址 [英] Display address of location on map
本文介绍了在地图上显示位置的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个Web应用程序,该应用程序在给定位置显示了标记.位置通过数据库传递.代码如下:
I write one web application which shows marker at given location. Locations are passed through database. The code is as follows:
try
{
sqlConnection.Open();
//Response.Write("Connection open");
SqlCommand cmd = sqlConnection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "selectCity";
SqlParameter iCity = cmd.Parameters.Add("@city", SqlDbType.NVarChar, 256);
iCity.Direction = ParameterDirection.Input;
iCity.Value = "Chennai";
SqlDataAdapter da =new SqlDataAdapter(cmd);
DataTable table = new DataTable();
da.Fill(table);
string strLocations = "";
string strTitle="";
//string strMessage="hello";
foreach(DataRow r in table.Rows)
{
string strLatitude;
string strLongitude;
string strMessage;
strLatitude = r["latitude"].ToString();
strLongitude = r["longitude"].ToString();
strMessage = r["massage"].ToString();
strLocations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + strLatitude + "," + strLongitude + ")));";
//strTitle += Environment.NewLine + "map.openInfoWindow(,document.createTextNode(" + strMessage + "));";
//strTitle += Environment.NewLine + "map.openInfoWindowHtml("+strMessage+");";
}
js.Text = @"<script type=''text/javascript''>
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById(''map_canvas'')); map.setCenter(new GLatLng(18.536644,73.851149), 2);
" + strLocations + @"map.setUIToDefault();
}
}
</script> ";
}
catch (Exception ex)
{
//Response.Write("Unable to open");45.05,7.6667
}
现在我想在地图上显示给定位置的地址.地址存储在位置(纬度,经度)之类的数据库中.我从数据库获取位置地址,但问题是我如何在地图上显示此地址.请帮我. 这很紧急.
谢谢.
Now I want to display address of given location on map.address is stored in database like location(latitude,longitude). I get address of location from database but problem is that how I show this address on map. Please help me. It''s urgent.
Thanks.
推荐答案
阅读文档很有帮助.
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html [^ ]
查找标题为信息窗口"的部分
It helps to read the documentation.
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html[^]
Look for the section title Info Window
这篇关于在地图上显示位置的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文