Baidu Map api-Baidu Map API development, using MarkerClusterer for point aggregation

Source: Internet
Author: User
For help, I developed a program to place marker on the map. it is completed through a function: functionaddMarker (getPoint, outContent, titleContent) {varopts {position: getPoint, location offset: newBMap. size (10, 0) sets the text offset} varlabelnewBMap. label (titleContent, opts); create a text annotation object labe... baidu Map api Baidu map phpjavascript

For help, I developed a program to place marker on the map, which is completed through a function:

Function addMarker (getPoint, outContent, titleContent) {var opts = {position: getPoint, // specify the geographic location of the text annotation offset: new BMap. size (10, 0) // set the text offset} var label = new BMap. label (titleContent, opts); // create a text annotation object label. setStyle ({color: "red", fontSize: "12px", height: "20px", lineHeight: "20px", fontFamily: ""}); var marker = new BMap. marker (getPoint); var infoWindow = new BMap. infoWindow (outContent, {width: 300}); // create an information window object // var titleWindow = new BMap. infoWindow (titleContent, {width: 50, height: 5}); map. addOverlay (marker); marker. addEventListener ("mouseover", function () {this. map. addOverlay (label) ;}); marker. addEventListener ("mouseout", function () {this. map. removeOverlay (label) ;}); marker. addEventListener ("click", function () {this. openInfoWindow (infoWindow); document. getElementById ('smallpic '). onload = function () {infoWindow. redraw ();}});}

Then, use the for loop to input functions such as the coordinates of each point that has been read, the label to be displayed, and the infowindow content to be popped up, and punctuation on the map:

 for (i = 0; i < locations.length; i++) {addMarker(point,readContent,titleContent); }

The problem is that there are many vertices and we need to use MarkerClusterer for Point Aggregation. However, if we create an array to import all coordinates as in the sample code, the aggregation is successful, however, the generated aggregation points do not contain labels and infowindow. it seems that the aggregation points directly generate a batch of new marker on them. How can I solve this problem? Thank you!

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.