使用谷歌api离线? [英] using google api offline ?
问题描述
hi
我创建简单的Web应用程序项目,以便在Google API地图上显示来自数据库的位置,问题是如何离线使用此应用程序?
i需要离线下载或使用Google地图吗?
这是我的代码:)
ASPX代码
hi
i create simple web application project to display location from database on Google API map , the question is how can i use this application offline ?
i need to download or using Google map offline ?
this is my code :)
ASPX code
<script type="text/javascript">
function initialize() {
var markers = JSON.parse('<%=ConvertDataTabletoString() %>');
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP,
marker:true
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function(marker, data) {
// Attaching a click event to the current marker
google.maps.event.addListener(marker, "click", function(e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
</script>
</head>
<body onload="initialize()">
代码落后:
protected void Page_Load (对象发送者,EventArgs e)
{
ConvertDataTabletoString();
}
public string ConvertDataTabletoString()
{
DataTable dt = new DataTable();
using(SqlConnection con = new SqlConnection( Data Source = x; Initial Catalog = googleDB; Integrated Security = true))
{
using(SqlCommand cmd = new SqlCommand(select title = City,lat =纬度,LN g =经度,来自tbl_Locations的描述,con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd );
da.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List< dictionary>< string,>> rows = new List< dictionary>< string,>>();
Dictionary< string,>行;
foreach(dt.Rows中的DataRow dr)
{
row = new Dictionary< string,>();
foreach(DataColumn col in dt.Columns)
{
row.Add(col.ColumnName,dr [col]);
}
rows.Add(row);
}
return serializer.Serialize(行);
}
}
}
code behind :
protected void Page_Load(object sender, EventArgs e)
{
ConvertDataTabletoString();
}
public string ConvertDataTabletoString()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection("Data Source=x;Initial Catalog=googleDB;Integrated Security=true"))
{
using (SqlCommand cmd = new SqlCommand("select title=City,lat=latitude,lng=longitude,description from tbl_Locations", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<dictionary><string,>> rows = new List<dictionary><string,>>();
Dictionary<string,> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string,>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);
}
}
}
推荐答案
不能您刚输入离线使用谷歌地图 [ ^ ]并查看了您的选项?
Couldn't you have just typed "use google maps offline[^]" and looked through your options?
这篇关于使用谷歌api离线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!