[OpenLayers-Users] Need help for Cluster strategy using externalGraphic

Xavier Mamano (jorix) xavier.mamano at gmail.com
Sat Mar 2 10:13:52 PST 2013


Hi,

It's not an easy task.

For styles you can use something like:

var myClusterStyleMap = OpenLayers.StyleMap({
    'default': new OpenLayers.Style({
            externalGraphic: '${myGrafic}',
            label: '${count}',
            ...
        }, {
            context: {
                count: function(feature) {
                    if (feature.cluster) { // is `.cluster` the array of
clustered features
                        return feature.cluster.length; // or
feature.attributes.count, is the same
                    } else { // is not clustered
                        return ''; // no label
                    }
                },
                myGrafic function(feature) {
                    if (feature.cluster) {
                        return ...my-cluster-grafic;
                    } else {
                        return ...my-feature-grafic;
                    }
                },
            ....
            }
        }
    })
});

Watch this proposal that allows easier use of popups and tooltips with the
clusters: 
  http://jorix.github.com/OL-FeaturePopups/examples/feature-popups.html

Regards,

Xavier Mamano



robertico wrote
> I've markers on my map after loading a kml file.
> <br>
> <br>
> The (default) icon is loaded from the kml file ( 
/
> extractStyles: true
/
>  )
> <br>
> I've also using a popup form for the kml markers. ( 
/
> extractAttributes 
/
> )
> <br>
> <br>
> I'd like to use cluster strategy but don't understand how to use it.
> <br>
> The only thing I need is to display a different icon for the clustered
> markers.
> <br>
> No fancy stuf like animated markers. Just a default icon for the non
> clustered markers 
> and another one for the clustered markers. 
> <br>
> <br>
> the final result should be;
> <br>
> - An icon for clusterd markers and after a marker click a popup form
> showing the number 
> of clustered markers.
> <br>
> - An icon for non-clustered markers and after a marker click a popup form
> showing the 
> extracted attributes from the kml file (this is the default)
> <br>
> <br>
> I've already tried several examples, but no luck so far.
> <br>
> <br>
> Any help appreciated,





--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Need-help-for-Cluster-strategy-using-externalGraphic-tp5037985p5038004.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list