-2
嗨我有一個數據表,我用JavaScriptSerializer。如何在覆蓋現有地圖時創建靜態標記?
public string Branches()
{
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=DB;User ID=sa;Password="))
{
new SqlCommand("Select title=BranchName,lat=Lat,lng=Lng,city=City,BranchID=BranchID
from Dealer where Lat >30", 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, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);
}
}
}
.aspx的:
我用這個數據表創建市場上贏得。
<body onload="initialize()">
<script type="text/javascript">
var markers = JSON.parse('<%=Branches() %>');
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
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 image = '/Images/branches.png';
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title + " : " + data.city,
icon: image,
}
);
(function (marker, data)
{
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
window.location = "Braches.aspx?DI=" + data.BranchID;
icon: InitIcon
});
})(marker, data);
}
我沒有任何問題,直到here.My地圖正在
但我想補充這方面的一些靜態標記地圖。
例如
標題= XYZ,LAT = 34.125444經度:42.122121,BranchID = 12345,圖像=圖像/ branchXYZ.png
標題= ABC,LAT = 32.125444經度:49.122121,BranchID = 67676,圖像=圖像/ branchABC.png
標題= DEF,LAT = 31.125444經度:47.122121,BranchID = 3434,圖像=圖像/ branchDEF.png
標題= GFH,LAT = 34.125444經度:42.122121,BranchID = 343434,image =圖片/ branchGFH.png
。
。
。
。
我該怎麼做?
這是你的answer.Thank你這麼多鄧肯 – Mhmt
優秀,歡迎您的me.Solved出色答卷 – duncan