Bing 地图 API - 删除图钉

发布于 2025-01-01 21:54:21 字数 119 浏览 1 评论 0原文

我有一个选择框,允许用户在用点填充 bing 地图的各种列表之间切换。

然而,当他们从列表中选择不同的位置时,我需要在绘制新的引脚之前删除旧的引脚。

有什么想法吗,API 文档似乎没有涵盖它?

I've got a select box which allows the user to toggle between various lists which populate a bing map with points.

However when they select a different location from the list I need to remove the old pins before plotting the new ones.

Any ideas, the API docs don't seem to cover it?

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

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

发布评论

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

评论(3

我的痛♀有谁懂 2025-01-08 21:54:21

要从地图中删除单个图钉(或任何其他类型的实体),您需要调用包含该图钉的实体集合的remove() 方法:http://msdn.microsoft.com/en-us/library/gg427616.aspx
或者,如果您想通过索引引用实体,请改用removeAt()。

要清除集合中的所有实体,请改为调用clear()方法。

To remove a single pushpin (or any other kind of entity) from the map, you need to call the remove() method of the entitycollection that contains the pin: http://msdn.microsoft.com/en-us/library/gg427616.aspx.
Or, if you want to reference the entity by index, use removeAt() instead.

To clear all entities from a collection, call the clear() method instead.

尐偏执 2025-01-08 21:54:21

只是为了把事情说清楚。让我花点时间来弄清楚。

在 JavaScipt 中创建图钉:

var thisPin;
var location new Microsoft.Maps.Location(YourLatitude, Your.longitude);


thisPin = new Microsoft.Maps.Pushpin(location, {
    icon: 'path to image',
    anchor: new Microsoft.Maps.Point(YourOffsetX, YourOffsetY)
});
map.entities.push(thisPin);

要删除图钉,您仍然必须让指针 thisPin 指向该特定图钉。

map.entities.remove(thisPin);

该方法在示例中没有得到很好的记录。

Just to make things clear. Cause it to me a while to figure it out.

Create a push pin in JavaScipt:

var thisPin;
var location new Microsoft.Maps.Location(YourLatitude, Your.longitude);


thisPin = new Microsoft.Maps.Pushpin(location, {
    icon: 'path to image',
    anchor: new Microsoft.Maps.Point(YourOffsetX, YourOffsetY)
});
map.entities.push(thisPin);

To remove the pin, you must still have the pointer thisPin pointing to that specific pin.

map.entities.remove(thisPin);

This method is not well documented in the samples.

最偏执的依靠 2025-01-08 21:54:21

javascript中的deleteAllShapes()会做到这一点,我现在正在做同样的事情并且它有效,

the deleteAllShapes() in the javascript will do this, i am working on the same thing now and it works,

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