2011-04-02 50 views
0

我正在使用gmap3 jquery插件,需要一点帮助。使用gmap3添加群集

我已经创建了一个看起来像

function getMarkers() { 
    $.getJSON("/Location/LocationData", null, function (data) { 
     var i, items = []; 
     //loop through values from service 
     $.each(data, function (key, val) { 
      lat = val.lat; 
      lng = val.long; 
      des = val.desc; 
      rating = val.rating; 
      items.push({ lat: val.lat, lng: val.long, data: val.desc }); 
      i++; 
     }); 

     $('#map_canvas').gmap3(
     { action: 'addMarkers', 
      radius: 100, 
      markers: items, 

      clusters: { 
       // This style will be used for clusters with more than 0 markers 
       0: { 
        content: '<div class="cluster cluster-1">CLUSTER_COUNT</div>', 
        width: 53, 
        height: 52 
       }, 
       // This style will be used for clusters with more than 20 markers 
       20: { 
        content: '<div class="cluster cluster-2">CLUSTER_COUNT</div>', 
        width: 56, 
        height: 55 
       }, 
       // This style will be used for clusters with more than 50 markers 
       50: { 
        content: '<div class="cluster cluster-3">CLUSTER_COUNT</div>', 
        width: 66, 
        height: 65 
       } 
      }, 
      events: { 
       click: function (marker, event, data) { 
        alert(data); 
       } 
      }, 

      callback: function (ref) { // get the cluster reference and save it in global variable 
       cluster = ref; 
      } 
     } 
    ); 


     //test to see output 
     //   $('<ul/>', { 
     //    'class': 'my-new-list', 
     //    html: items.join('') 
     //   }).appendTo('#list'); 


    }); 

} 

一切工作,因为我不过期待我想稍微修改簇是如何被应用的功能。我有一个可变的评级,返回1-10分。根据评分数量是否可以增加强度?

例如我在地图上有一个4针的簇,并且所有针的等级都是5.我有另一个4针的簇,只有1的等级。

是否可以创建一个公式,以便第一个簇将显示4 +(4 * 5),而不是只显示4它的显示24和第二个群集将只显示9?

回答

0

gmap3.js功能_displayClusters(1246)

修改内容:样式[米] .content.replace( 'CLUSTER_COUNT',_compute_formula(cl.idx.length)),

它5中未9对于第二个群集?