[OpenLayers-Users] Displaying a popup on mouse over AND a different popup on click.

Adrian Popa adrian_gh.popa at romtelecom.ro
Mon Aug 3 03:54:08 EDT 2009


Hello everyone,

This is sort of a repeat message of "Re: [OpenLayers-Users] 
Labels/Tooltips on mouse over a Vector layer" - but with a slightly 
different idea.

Problem: I want to display a small div/popup with the marker's name when 
the user hovers his mouse over the location, and I want to display a 
bigger popup when the user actually clicks on the location.

Current status:
* I can use {hover: true} to register featureselected/featureunselected 
when I hover over a marker instead on when I click on the maker.
* I haven't found any events that could differentiate between hover and 
click

I'm thinking I could register my select control with hover: true and 
allow featureselected to execute the same function for both when I click 
on the makrer as well as when I hover over the marker. I would  like to 
know if there's any way to find out in the event inside the function if 
the user clicked or not his mouse. Depending on this, I would show one 
popup or the other.

Something like:

select = new OpenLayers.Control.SelectFeature(markers, {clickout:true, 
hover:true});
        markers.events.on({ "featureselected": onMarkerSelect, 
"featureunselected": onMarkerUnselect, "visibilitychanged": 
onMarkerToggle });
        map.addControl(select);
        select.activate();

function onMarkerSelect(event){
    var feature = event.feature;
    //find out if the user clicked or not
    var clicked = event.*findAWayToSeeIfTheUserClicked()*;
    if(clicked){
       //show larger popup
    }
    else{
       //show smaller popup
    }
}

Suggestions are welcome.

Thanks,
Adrian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090803/1e68bd67/attachment.html


More information about the Users mailing list