如何仅在地图的可视区域中显示图钉
我正在尝试在地图上显示图钉,但由于我有很多图钉,我只想显示地图可视区域内的图钉,这有望使地图更具响应性。
我从数据库查询中获取 xy 点列表。 这是我到目前为止所拥有的代码。
List<Pushpin> ListofPoints = new List<Pushpin>();
foreach (var element in query)
{
//Add a pin to the map
Pushpin pushpin = new Pushpin();
Location location = new Location();
location.Latitude = Convert.ToDouble(element.X);
location.Longitude = Convert.ToDouble(element.Y);
pushpin.Location = location;
ListofPoints.Add(pushpin);
map1.Children.Add(pushpin);
}
// Position map based on a collection of Pushpins points
var x = from l in ListofPoints
select l.Location;
map1.SetView(LocationRect.CreateLocationRect(x));
ListofPoints.Clear();
任何人都可以给我关于如何仅在地图的可视区域上显示点的任何建议/代码吗?
谢谢
I am trying to display pushpins on a map but as i have lots of pushpins i only want to display the ones within the viewable area of the map which should hopefully make the map more responsive.
I get my list of x y points from a query to a database.
This is the code I have so far..
List<Pushpin> ListofPoints = new List<Pushpin>();
foreach (var element in query)
{
//Add a pin to the map
Pushpin pushpin = new Pushpin();
Location location = new Location();
location.Latitude = Convert.ToDouble(element.X);
location.Longitude = Convert.ToDouble(element.Y);
pushpin.Location = location;
ListofPoints.Add(pushpin);
map1.Children.Add(pushpin);
}
// Position map based on a collection of Pushpins points
var x = from l in ListofPoints
select l.Location;
map1.SetView(LocationRect.CreateLocationRect(x));
ListofPoints.Clear();
Can anyone give my any advice/code on how to only display the points on the viewable area of map?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
ViewChangeStart
和ViewChangeEnd
事件获取更改后的当前视图,然后重新查询数据集并根据需要更新显示的引脚。Use the
ViewChangeStart
andViewChangeEnd
events to get the current view after the change and then requery your dataset and update the displayed pins as necessary.