最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bing Maps API - Remove Pins - Stack Overflow

programmeradmin5浏览0评论

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?

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?

Share Improve this question asked Feb 3, 2012 at 21:45 CLiownCLiown 13.8k50 gold badges127 silver badges205 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

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./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.

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.

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

发布评论

评论列表(0)

  1. 暂无评论