Home  >  Article  >  Web Front-end  >  How to remove marker overlay using Baidu Maps

How to remove marker overlay using Baidu Maps

亚连
亚连Original
2018-06-09 13:43:552355browse

Now I will share with you a method to remove the marker covering or the maker's label text on Baidu Map. It has a good reference value and I hope it will be helpful to everyone.

is as follows:

var marker = new BMap.Marker(...);
//方法1
map.removeOverlay(marker);
//方法2
marker.remove(); 
//如果是Marker设置的setLabel还可以设置其样式来隐藏 
mapComponent.state.bikeMarkLabel.setStyle({
  display:"none"
}); 41787

The label method is the same as the marker.

It is recommended to use method 1 and method 2. Method 3 only hides rather than clears

I recently used Baidu map api to do a project, and I need to display markers on the map at the same time. and Polyline, and Polyline needs to be displayed or cleared based on clicks, so I encountered the problem of clearing the specified coverage. After various searches, I could not find a perfect solution. Through my own thinking, I found a way to solve this problem and posted it. Share it with everyone. Okay, let’s get to the point:

There are two methods for clearing overlays: map.removeOverlay() or map.clearOverlays(). The clearOverlays() method removes all overlays at once, and removeOverlay() removes them all at once. A designated overlay, obviously, I want to remove a class of Polyline overlays at a time, neither method works.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Using vue to implement secondary route setting method

react project development

Implementing multiple routing implementations in Vue-Router2.X

Using routing and hook functions in Vue2.X

Details Interpretation of react controlled components and uncontrolled components

Vuejs single file component (detailed tutorial)

Using image delay in vue-lazyload Load plugin

The above is the detailed content of How to remove marker overlay using Baidu Maps. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn