如何仅在地图的可视区域中显示图钉

发布于 2024-11-19 15:22:11 字数 929 浏览 4 评论 0原文

我正在尝试在地图上显示图钉,但由于我有很多图钉,我只想显示地图可视区域内的图钉,这有望使地图更具响应性。

我从数据库查询中获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌上青苔 2024-11-26 15:22:11

使用 ViewChangeStartViewChangeEnd 事件获取更改后的当前视图,然后重新查询数据集并根据需要更新显示的引脚。

Use the ViewChangeStart and ViewChangeEnd events to get the current view after the change and then requery your dataset and update the displayed pins as necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文