[Users] Mouserover Events

Stefan Schwarzer stefan.schwarzer at unepgrid.ch
Thu Aug 12 07:38:20 CEST 2010


Just for the notes: it works like this:

	selectControl = new OpenLayers.Control.SelectFeature(
		vecLayer,
		{ 
			hover: true 
		}
	);

	map.addControl(selectControl);
	selectControl.activate();

	vecLayer.events.on({
		featureselected: function(e)
		{
			createPopup(e.feature);
		},
		featureunselected: function(e)
		{
			popup.destroy(e.feature)
		}
	});


	function createPopup(feature)
	{
		var content = "<div style='font-size:.9em; width:270px;'><b>" + feature.attributes.name + "</b><hr />" + "</div>";
		popup = new GeoExt.Popup({
			title: 'Details',
			feature: feature,
			width:270,
			height:170,
			html: content,
			collapsible: true
		});
		popup.on({
			close: function() 
			{
				if(OpenLayers.Util.indexOf(vecLayer.selectedFeatures, this.feature) > -1) 
				{
					selectControl.unselect(this.feature);
				}
			}
		});
		popup.show();
	}


Thanks for the tips!

Stef

On Aug 10, 2010, at 9:49 PM, Adam Ratcliffe wrote:

> Hi Stefan,
> 
> I haven't used the 'hover' myself but the docs say "
> 
> Cheers
> Adam
> 
> On 10/08/2010, at 11:10 PM, Stefan Schwarzer wrote:
> 
>> 
>>> Have you tried the 'hover' constructor option for the SelectFeature control?  http://dev.openlayers.org/apidocs/files/OpenLayers/Control/SelectFeature-js.html
>> 
>> Cool, working!!
>> 
>> selectControl = new OpenLayers.Control.SelectFeature(vecLayer,{ hover: true});
>> 
>> However, any idea how I can close then the popups automatically again?
>> 
>> Warmest thanks for the tips!
>> 
>> Stef
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100812/d410fb6e/attachment.htm 


More information about the Users mailing list