开发者

How do I display push pins only in viewable area of map

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜