Using Baidu API to draw polygons, can not monitor Baidu graphics mouse events

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.