The following code copy to Baidu map of the demo run, the effect is that I want to design the effect.
Function: Bulk Delete maker in a region.
Function of the design idea:
1 Right Menu-"regional deletion mechanism."
2 Draw a circle first (with a mouse click on a point to draw a circle center point).
3 Gets the callout (primary key) that is selected in the circle.
Right-click Delete on 4 circle
4.1 Determine to delete the circle, delete the callout (connect the database data).
4.2 Cancels the Delete circle.
Main function code (JS);
Http://developer.baidu.com/map/reference/index.php?title=Class:%E8%A6%86%E7%9B%96%E7%89%A9%E7%B1%BB/Circle
{text: ' area deletion mechanism ', callback:function (e) {var mpoint=new bmap.point (E.lng,e.lat);/Get center point coordinates//a JS draw circle but this can not repeat the circle need to refresh the page before you can To redraw the circle/* var circle = new Bmap.circle (mpoint,1000,{fillcolor: "Blue", Strokeweight:1, fillopacity:0.3, strokeopacity:0.3
, enableediting:true}); Map.addoverlay (circle);
* * var circle = new Bmap.circle (mpoint,5000); Circle.setfillcolor ("Blue");
Fill Color circle.setstrokeweight (1);//Set the width of the circle edge, with an integer greater than or equal to 1.
Circle.setfillopacity (0.3);//Returns the fill transparency of the circle.
Circle.setstrokeopacity (0.3);//Set the edge transparency of the circle, take the value range 0-1. This circle can be edited circle the two JS code position can not be changed map.addoverlay (circle);//Add the circle to the map circle.enableediting ()//Set editable circle var removecircle = func tion (e,ee,marker) {var deleteid=[], var idd=[];//Get all the covers on the map var overlays = map.getoverlays ();//Get the circle area var bounds = Mark
Er.getbounds ();
var maker_arr = [];
var maker_id =[]; for (Var i=0;i<overlays.length;i++) {///judge the overlay is annotated and is within the circular region of the IF (Overlays[i].uq = = "Marker") {//Get the distance from the callout point to the center of the circle to compare if ( Map.getdistance (Marker.getcenter (), overlays[i].getposition ())< Marker.getradius ()) {Maker_arr.push (overlays[i]);
Maker_id.push (overlays[i].id);//Callout primary key value}} $.messager.confirm (' Confirm ', ' Are you sure you want to delete the selected callout in the zone? ', function (r) {if (r==true) { Map.removeoverlay (circle)/delete circle for (Var i=0;i<maker_id.length;i++) {$.ajax ({type: ' delete ', url: '/yxt-admin/admin /hospital/' + maker_id[i] + '/delete ', success:function (data) {if (Data.statecode = =) {$.messager.show ({title: ' mentioning
Message ', Msg:data.message, timeout:5000, ShowType: ' Slide '}); }else if (data.statecode==205) {$.messager.alert (' reminder ', ' login has timed out login ', ' info ', function () {top.location.href= '/yxt-admin
/adminlogin.html ";
}); else {$.messager.show ({title: ' Hint ', msg:data.message});}, Error:function (XMLHttpRequest, Textstatus, Errorthrown {$.messager.show ({title: ' Hint ', msg: ' System error, please contact the developer.) or refresh the current page and rerun.
'
});
}
});
} location.reload ();
}else{Map.removeoverlay (Circle)}})} var circlemenu=new bmap.contextmenu (); Circlemenu.additem (New Bmap.menuitem (' delete ', Removecircle.bind (removecircle))); Circle Up RightKey to delete Circle.addcontextmenu (circlemenu);//Add Right-click menu}},
The above is a small set of JS code to introduce the realization of Baidu Map drawing circle To delete the callout, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!