【问题标题】:Using gmap3 adding clusters使用 gmap3 添加集群
【发布时间】:2011-04-02 19:52:35
【问题描述】:

我正在使用 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?

【问题讨论】:

    标签: jquery jquery-plugins jquery-gmap3


    【解决方案1】:

    gmap3.js 函数_displayClusters (1246)

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 2017-08-04
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多