从 Bing 地图中删除图钉

发布于 2024-11-29 11:52:19 字数 373 浏览 4 评论 0原文

我不太明白为什么这不起作用:(Bing 映射 silverlight 控件 WP7)

在此处添加图钉:

GeoCoordinate location = new GeoCoordinate();
location.Latitude = 51.5;
location.Longitude = 0;
pushpin1.Location = location;               
map1.Children.Add(pushpin1);

在此处删除图钉:

map1.Children.Remove(pushpin1);

这不会删除图钉,我做错了什么?

谢谢。

I do not quite understand why this isnt working: (Bing maps silverlight control WP7)

Add a pushpin here:

GeoCoordinate location = new GeoCoordinate();
location.Latitude = 51.5;
location.Longitude = 0;
pushpin1.Location = location;               
map1.Children.Add(pushpin1);

Remove the pushpin here:

map1.Children.Remove(pushpin1);

This wont remove the pushpin, what am I doing wrong?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

星軌x 2024-12-06 11:52:19

我让它与以下代码一起工作:

    private void AddPushpinButton_Click(object sender, RoutedEventArgs e)
    {
        GeoCoordinate location = new GeoCoordinate() { Latitude = 51.5, Longitude = 0 };
        Pushpin pushpin1 = new Pushpin() { Location = location, Tag = "FindMeLater" };
        map1.Children.Add(pushpin1);
    }

    private void RemovePushpinButton_Click(object sender, RoutedEventArgs e)
    {
        var pushpin = map1.Children.First(p => (p.GetType() == typeof(Pushpin) && ((Pushpin)p).Tag == "FindMeLater"));
        map1.Children.Remove(pushpin);
    }

I got this to work with the following code:

    private void AddPushpinButton_Click(object sender, RoutedEventArgs e)
    {
        GeoCoordinate location = new GeoCoordinate() { Latitude = 51.5, Longitude = 0 };
        Pushpin pushpin1 = new Pushpin() { Location = location, Tag = "FindMeLater" };
        map1.Children.Add(pushpin1);
    }

    private void RemovePushpinButton_Click(object sender, RoutedEventArgs e)
    {
        var pushpin = map1.Children.First(p => (p.GetType() == typeof(Pushpin) && ((Pushpin)p).Tag == "FindMeLater"));
        map1.Children.Remove(pushpin);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文