Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I successfully used the AnimatedCluster plugin for OpenLayers. My codes uses OpenLayers.Rules and symbolizers. How can I get a "pointer" like mouse cursor when hovering over a cluster of features?

My code is as follows (works perfect, except not displaying a mouse over pointer like cursor). cursor: "pointer" as well as highlightCtrl does not seem to have any impact, the mouse cursor does not change to "pointer":

// Define three colors that will be used to style the cluster features
// depending on the number of features they contain.
var colors = {
    low: "rgb(181, 226, 140)", 
    middle: "rgb(241, 211, 87)", 
    high: "rgb(253, 156, 115)"
};

// Define rules to style the cluster features.
var oneMarkerRule = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.EQUAL_TO,
        property: "count",
        value: 1
    }),
    symbolizer: {
        cursor: "pointer", // DOESN'T HAVE ANY IMPACT
        externalGraphic: "${getExternalGraphic}",
        fillOpacity: 0.9, 
        pointRadius: 10
    }
});

var lowRule = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.BETWEEN,
        property: "count",
        lowerBoundary: 2,
        upperBoundary: 14
    }),
    symbolizer: {
        cursor: "pointer", // DOESN'T HAVE ANY IMPACT
        fillColor: colors.low,
        fillOpacity: 0.9, 
        strokeColor: colors.low,
        strokeOpacity: 0.5,
        strokeWidth: 12,
        pointRadius: 10,
        label: "${count}",
        labelOutlineWidth: 1,
        fontColor: "#ffffff",
        fontOpacity: 0.8,
        fontSize: "12px"
    }
});

var middleRule = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.BETWEEN,
        property: "count",
        lowerBoundary: 15,
        upperBoundary: 50
    }),
    symbolizer: {
        cursor: "pointer", // DOESN'T HAVE ANY IMPACT
        fillColor: colors.middle,
        fillOpacity: 0.9, 
        strokeColor: colors.middle,
        strokeOpacity: 0.5,
        strokeWidth: 12,
        pointRadius: 15,
        label: "${count}",
        labelOutlineWidth: 1,
        fontColor: "#ffffff",
        fontOpacity: 0.8,
        fontSize: "12px"
    }
});

var highRule = new OpenLayers.Rule({
    filter: new OpenLayers.Filter.Comparison({
        type: OpenLayers.Filter.Comparison.GREATER_THAN,
        property: "count",
        value: 50
    }),
    symbolizer: {
        cursor: "pointer", // DOESN'T HAVE ANY IMPACT
        fillColor: colors.high,
        fillOpacity: 0.9, 
        strokeColor: colors.high,
        strokeOpacity: 0.5,
        strokeWidth: 12,
        pointRadius: 20,
        label: "${count}",
        labelOutlineWidth: 1,
        fontColor: "#ffffff",
        fontOpacity: 0.8,
        fontSize: "12px"
    }
});

var markerContext = {
        getExternalGraphic: function(feature) {
            var defaultIcon = 'my_icon.png'; //
            var iconPaths = {
                '4053': 'icon4053.png', 
                '4054': 'icon4054.png'
            };
            var type = feature.attributes.type || feature.cluster[0].attributes.type[0];
            var path = iconPaths[type];   
            if (!path) {
                path = defaultIcon;
            }
            return path;
        }
};

// Create a Style that uses the three previous rules
var vectorStyleMap = new OpenLayers.Style(
    {
        "temporary": { cursor: "pointer" }
    }, 
    {
        context: markerContext,
        rules: [oneMarkerRule, lowRule, middleRule, highRule]
    }
);  


var animatedClusterStrategy = new OpenLayers.Strategy.AnimatedCluster({
    distance: 40,
    animationMethod: OpenLayers.Easing.Expo.easeOut,
    animationDuration: 30
});

//Call constructor
var vector = OpenLayers.Layer.Vector(
    styleMap: vectorStyleMap,
    renderers: ['Canvas','SVG'],
    strategies: [animatedClusterStrategy],
);        

//add mouse-over event
var highlightCtrl = new OpenLayers.Control.SelectFeature(this, {
    hover: true,
    highlightOnly: true,
    renderIntent: "temporary"
});

//add map controller
this.mapParent.map.addControl(highlightCtrl);  // DOESN'T HAVE ANY IMPACT
highlightCtrl.activate();  // DOESN'T HAVE ANY IMPACT
share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.