var drawingmanager = new Bmaplib.drawingmanager (map, {
Isopen:false,//whether to turn on draw mode
Enabledrawingtool:true,//whether the toolbar is displayed
Drawingtooloptions: {
Anchor:bmap_anchor_top_right,//Location
Offset:new bmap.size (5, 5),//deviation value
scale:0.8,//tool bar Scale
Toolbar display Data
drawingmodes:[
Bmap_drawing_marker,
Bmap_drawing_polygon
]
},
Polylineoptions:styleoptions,//Line style
Polygonoptions:styleoptions,//Polygon style
Rectangleoptions:styleoptions//Rectangle style
});
Drawing callback function
Drawingmanager.addeventlistener (' Overlaycomplete ', overlaycomplete);
Callback after completion
var overlaycomplete = function (e) {
Alert (' End ');
Map.removeoverlay (Pointarray[0]); Clear last Marker
Pointarray = [];
Overlays.push (E.overlay); Save user-clicked coordinates in an array for easy removal
GetPoint (e.overlay.$);
Pointarray.push (E.overlay);
Alert (' End ');
Alert (' Monitor to Polygon completion event ');
alert (E.drawingmode);
alert (E.overlay);
alert (e.calculate);
alert (E.label);
};
The problem with the code above is that the function does not have to be defined beforehand to monitor and callback the event, so the call is unsuccessful.
var drawingmanager = new Bmaplib.drawingmanager (map, {
Isopen:false,//whether to turn on drawing mode
Enabledrawingtool:true,//whether the toolbar is displayed;
Drawingtooloptions: {
Anchor:bmap_anchor_top_right,//Location
Offset:new bmap.size (5, 5),//deviation value
scale:0.8,//toolbar zoom
//toolbar display data
Drawingmodes : [
bmap_drawing_marker,
bmap_drawing_polygon
]
},
Polylineoptions : styleoptions,//Line style
Polygonoptions:styleoptions,//Polygon style
Rectangleoptions:styleoptions// The style of the rectangle
});
Callback after completion
var overlaycomplete = function (e) {
Alert (' End ');
Map.removeoverlay (Pointarray[0]); Clear last Marker
Pointarray = [];
Overlays.push (E.overlay); Save user-clicked coordinates in an array for easy removal
GetPoint (e.overlay.$);
Pointarray.push (E.overlay);
Alert (' End ');
Alert (' Monitor to Polygon completion event ');
alert (E.drawingmode);
alert (E.overlay);
alert (e.calculate);
alert (E.label);
};
Drawing callback function
Drawingmanager.addeventlistener (' Overlaycomplete ', overlaycomplete);
Using Baidu API to draw polygons, can not monitor Baidu graphics mouse events