Mahesh.D
Mahesh.D

Reputation: 1689

How to convert onClick to hover in OpenLayers

I'm using OpenLayers map in my project,I'm displaying list of items on map.Whenever user clicks on item(feature) then item description will be popup instead of onClick,I want to convert to hover.To do this where I need to modify ?

Upvotes: 2

Views: 511

Answers (1)

olly_uk
olly_uk

Reputation: 11865

I'm not sure where you need to modify as you have not provided your code. However below is a snippet taken from the OpenLayers example found here.

        var report = function(e) {
            OpenLayers.Console.log(e.type, e.feature.id);
        };

        var highlightCtrl = new OpenLayers.Control.SelectFeature(vectors, {
            hover: true,
            highlightOnly: true,
            renderIntent: "temporary",
            eventListeners: {
                beforefeaturehighlighted: report,
                featurehighlighted: report,
                featureunhighlighted: report
            }
        });

so i would hazard a guess that you will need to simply add the line hover: true to your SelectFeature config, to fully select you could remove the line highlightOnly: true or change it to false. Also your report function would have your code for displaying a popup.

again, not sure this is what you need to do, if you post your code it will be easier to help.

Olly

Upvotes: 1

Related Questions