我有一個帶有緯度和經度的 SQL Server 資料庫,我已通過 EF 將其匯入到我的WPF C#應用程式中。

現在在我的應用程式中,我匯入了 Bing 地圖,我想從通過 EF 查詢獲得的資料創建圖釘。
private void LoadPins()
{
var result = (from s in PE.tbl_SafeSpace
select new
{ s.lat, s.@long }).ToList();
for (int i = 0; i < result.Count; i )
{
Pushpin pin = new Pushpin();
pin.Location = new Location(result[i]);
// Adds the pushpin to the map.
bMaps.Children.Add(pin);
}
}
我知道我在將資料放入該位置時做錯了什么,但我不確定是什么。
uj5u.com熱心網友回復:
一個建議,如果您遇到錯誤,請在此處發表評論,我很樂意更新我的答案。
private void LoadPins()
{
List<Location> result = (from s in PE.tbl_SafeSpace
select new Location
{
Latitude = (double)s.lat,
Longitude =(double)s.long
}).ToList();
foreach(Location location in result)
{
Pushpin pin = new Pushpin();
pin.Location = location;
// Adds the pushpin to the map.
bMaps.Children.Add(pin);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/356455.html
