[OpenLayers-Users] Displaying a popup on mouse over AND a
different popup on click.
Alexandre Dube
adube at mapgears.com
Mon Aug 3 08:12:04 EDT 2009
Hi Adrian,
Take a look at this example (1). You can use 2 SelectFeature controls
for what you need, one with hover:true and highlightOnly:true, the other
with hover false. The first one won't actually select the feature and
you can register 3 kinds of "highlight" events (see the source) to
display your small div/popup.
Hope this helps,
Alexandre
(1) http://openlayers.org/dev/examples/highlight-feature.html
Adrian Popa wrote:
> 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
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Alexandre Dubé
Mapgears
www.mapgears.com
More information about the Users
mailing list