我想在Bing地图上绘制多个推针/多边形,我有Windows 8.1,在我的数据变量中它有4个值,但它没有在地图上显示任何内容。
foreach (tblUsers item in data)
{
Location location = new Location();
// item.dLatitude; item.dLongitude;
DDataFromDB.userID = item.nUserId;
DDataFromDB.dID = item.nDid;
DDataFromDB.dLatitude = item.dLatitude;
DDataFromDB.dLongitude = item.dLongitude;
DDataFromDB.dDate = item.dtAddDate;
DDataFromDB.dStatus = item.strStatus;
MapLayer layer0 = new MapLayer();
Pushpin pushpin = new Pushpin();
pushpin.Text = "1";
MapLayer.SetPosition(pushpin, new Location( DDataFromDB.dLatitude, DDataFromDB.dLongitude));
Map _map = new Map();
_map.Children.Add(pushpin);
}
答案 0 :(得分:0)
首先看起来你正在创建一个包含循环中每个图钉的地图。你应该只创建一个地图,它应该在XAML中(大部分时间),看起来应该是这样的:
<Page
x:Class="BingMapsIntro_WinRT_CS.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:Bing.Maps">
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<m:Map Name="MyMap" Credentials="YOUR_BING_MAPS_KEY"/>
</Grid>
</Page>
然后在你的代码中获取这两行代码:
Map _map = new Map();
_map.Children.Add(pushpin);
并添加以下代码:
MyMap.Children.Add(pushpin);