Search code examples
javascriptperformanceopenlayersopenlayers-3

Openlayers 3 performance markers


I have an Openlayers3 map with a lot of markers and I would like to handle it more efficiently.

I saw there was a cluster method on the last version of Openlayers and I would like to use the same thing on the third version : http://openlayers.org/dev/examples/strategy-cluster.html

Do I have to use vectors ?

Here is my current code :

$.getJSON( "http://localhost/folder/address.json", function(data){

     for(var k in data) {

      var companyCity = data[k].city;
      var companyName = data[k].company;
      var companyLocation = data[k].address;
      var companyLat = data[k].lat;
      var companyLng = data[k].lng;
      var companyPosition = transform([companyLng,companyLat]);

       var elt = $('<p title="'+ companyName +': '+ companyLocation +', '+ companyCity +'"></p>').css({

        "width": '5px',
        "height": '5px',
        "border-radius": '50%',
        "background-color": '#E64411',
        "opacity" : '.5'

       });



       var marker = new ol.Overlay({
        map: map,
        position: companyPosition,
        element: elt
       });


    }
  });

Someone has already done it ?


Solution

  • I know this post is old but there is a Clustering example now.