百度地圖api-百度地圖API開發,使用MarkerClusterer進行點彙總的問題

來源:互聯網
上載者:User
關鍵字 百度地圖api 百度地圖 php javascript
百度地圖api百度地圖phpjavascript

新手求助,我開發的程式在地圖上放置marker,是通過一個函數完成的:

 function addMarker(getPoint,outContent,titleContent){ var opts = { position : getPoint, // 指定文本標註所在的地理位置 offset : new BMap.Size(10, 0) //設定文本位移量 } var label = new BMap.Label(titleContent, opts); // 建立文本標註對象 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}); // 建立資訊視窗對象 // 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();}  }); }

然後再用for迴圈將已經讀取好的每個點的座標、需要顯示的label、需要彈窗的infowindow的內容等輸入函數,在地圖上標點:

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

現在的問題是點很多,需要用MarkerClusterer進行點彙總,但是如果按照範例程式碼那樣,建一個數組將座標全部匯入,彙總是成功了,但產生的彙總點是沒有label和infowindow的,感覺像是彙總點是直接產生了一批新的marker蓋在上面了。請問要怎麼寫才能解決這個問題?謝謝!

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.