In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "javascript delete designated coverage method is what", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "javascript delete designated coverage method is what" it!
Baidu Maps provides a way to remove all coverings, as well as a way to delete specified coverings. Delete all the coverings needless to say, delete at any time, the code is just one sentence: map.clearOverlays ()
However, it is not easy for many newcomers to delete the specified overlay.
Reason: declared variables, not stored independently, do not know how to find the variable, and then pass the variable as a parameter to perform deletion.
This article first provides a way to delete a specified type of overlay:
/ / openGPS.cn prompt: delete all broken line coverings function clearAllPolyline () {var allOverlay = map.getOverlays (); for (var I = 0; I < allOverlay.length; iTunes +) {if (allOverlay [I] .toString () = "[object Polyline]") {map.removeOverlay (allOverlay [I]) } / / openGPS.cn prompt: delete all lable coverings function clearAllLable () {var allOverlay = map.getOverlays (); for (var I = 0; I < allOverlay.length) Map.removeOverlay +) {if (allOverlay [I] .toString () = = "[object Marker]") {map.removeOverlay (allOverlay.toString ()); / / pay attention to how to get lable}
Then, before talking about how to delete a particular cover, there is a premise: before creating a cover that needs to be manipulated, you need to assign an id to it. In my example, all the Marker attributes are assigned an id to the Marker object using marker.imei = "xxxxxx"; (tip: remember the syntax features of js, direct attribute assignment can be used), traversal with the check of the id to delete the overlay.
/ * openGPS.cn hint: in my example, all Marker attributes are marker.imei = "xxxxxx" Assigns an id to the Marker object, so my way of writing is: get all the coverings first: then determine whether the overlay is of Marker type; then determine whether it is the id (imei) I want to delete; then get the target object and perform the delete operation * / function getMapMarker (imei) {var reMarker = null Var allOverlay = map.getOverlays (); for (var I = 0; I < allOverlay.length; iTunes +) {if (overlay [I] .toString () = "[object Marker]") {if (overlay [I] .getTitle () = imei) {reMarker = allOverlay [I]; break } return reMarker;} Thank you for your reading, the above is the content of "what is the method for javascript to delete specified coverings". After the study of this article, I believe you have a deeper understanding of what the method of deleting designated coverings by javascript is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.