开发者

Using gmap3 adding clusters

I am using the gmap3 jquery plugin and need a little help.

I have created a function that looks like

 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');


    });

}
开发者_JAVA技巧

Everything works as I am expecting however I want to slightly modify how the clusters are been applied. I have have a varible 'rating' that returns a rating 1-10. Is it possible to add strength to the cluster depending on the rating number?

e.g. I have a cluster of 4 pins on the map and all of the pin's have a rating of 5. I have another cluster of 4 pins with only a rating of 1.

Is it possible to create a formula so the first cluster will display 4 + (4*5) so instead of just displaying 4 its displaying 24 and the 2nd cluster will only display 9?


gmap3.js function _displayClusters (1246)

modify content:styles[m].content.replace('CLUSTER_COUNT', _compute_formula(cl.idx.length)),

it's 5 not 9 for 2nd cluster ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜