Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. var style = new OpenLayers.Style({ pointRadius: "${radius}", fillColor: "#ffcc66", fillOpacity: 0.8, strokeColor: "#cc6633", strokeWidth: 1, strokeOpacity: 0.8, label: "${getLabel}" }, {
  2. context: {
  3. getLabel: function(feature) {
  4. if (feature.cluster) {
  5. if (feature.cluster.length > 1) {
  6. return feature.cluster.length;
  7. }
  8. }
  9. return '';
  10. },
  11. radius: function(feature) {
  12. var pix = 2;
  13. if(feature.cluster) {
  14. pix = Math.min(feature.attributes.count, 7) + 3;
  15. }
  16. return pix;
  17. }
  18. }
  19. });
  20.  
  21. strategy = new OpenLayers.Strategy.Cluster();
  22.  
  23. featureSubVector = new OpenLayers.Layer.Vector("Clusters", {
  24. strategies: [strategy],
  25. styleMap: new OpenLayers.StyleMap({ "default": style, "select": { fillColor: "#8aeeef", strokeColor: "#32a8a9" } })
  26. });
  27.  
  28. var selectControl = new OpenLayers.Control.SelectFeature( featureSubVector, {hover: true} );
  29. map.addControl(selectControl);
  30. selectControl.activate();
  31. map.addLayer(featureSubVector);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement