0

我正在使用 gmap3 jquery 插件,需要一些帮助。

我创建了一个看起来像的函数

 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?

4

1 回答 1

0

gmap3.js 函数 _displayClusters (1246)

修改内容:styles[m].content.replace('CLUSTER_COUNT', _compute_formula(cl.idx.length)),

第二个集群是 5 而不是 9?

于 2011-04-20T19:14:46.403 回答