- Home >
- Documentation >
- Misc >
- clear
clear
This function allows to remove objects from a map
Usage
Parameters
- id {string|array of string} Id of the object to remove (optional)
- name {string|array of string} Object type to remove (marker, rectangle, ...) (optional)
- first {bool} Only the first objects added (optional)
- last {bool} Only the last objects added (optional)
- tag {function(tag):bool|string|array of string} User tag on object (optional)
Example
$('#test').gmap3({
map:{
options:{
center:[46.578498,2.457275],
zoom: 5
}
},
marker:{
values:[
{latLng:[48.8620722, 2.352047], id:"mTagX"},
[46.59433,0.342236],
[42.704931, 2.894697]
]
},
circle:{
values:[
{ options:{
center: [47.34329,5.028076],
radius : 250000,
fillColor : "#F4AFFF",
strokeColor : "#CB53DF"
},
tag: "transient"
},
{ options:{
center: [47.34329,5.028076],
radius : 125000,
fillColor : "#008BB2",
strokeColor : "#005BB7"
}
}
]
},
rectangle:{
options:{
bounds: {ne:[47.238965,-1.607666], sw:[48.404409,-4.508057]},
radius : 750,
fillColor : "#008BB2",
strokeColor : "#005BB7"
},
tag: ["rad750", "transient", "blue"]
}
});
// 1) remove the last marker added and the last circle added
setTimeout(function(){
$('#test').gmap3({
clear: {
name:["marker", "circle"],
last: true
}
});
}, 2000);
// 2) remove overlay with some specified tags
setTimeout(function(){
$('#test').gmap3({
clear: {
tag: ["transient", "anyOtherTag"]
}
});
}, 3000);
// 3) remove object with a specific id
setTimeout(function(){
$('#test').gmap3({
clear: {
id: "mTagX"
}
});
}, 4000);
Note: to remove an object with a precise id, the clear function can be simplified by a string, in the previous example, the last one should have been reduce by :
clear: "mTagX"


