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!