Hey Cédric!
Thank you for pointing me in the right direction! Seeing an actual
example that does exactly what I was looking for was helpful. Although
they do this via MapFish, I still could derive at least that it's
possible from a performance point of view, which helped me figure it
out with your documentation and other stuff on the internet.
For anyone who wants to accomplish the same thing, here is how I
incorporated this feature:
OpenLayers.Control.Hover = OpenLayers.Class(OpenLayers.Control,
{
defaultHandlerOptions: {
'delay': 100,
'pixelTolerance': null,
'stopMove': false
},
initialize: function(options)
{
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Hover(
this, {'move': this.onMove}, this.handlerOptions
);
},
onMove: function(evt)
{
if(!hoverTO)
{
hoverTO = true;
window.setTimeout("resetHoverTO()", 200);
var format = new OpenLayers.Format.GeoJSON({ignoreExtraDims:
true});
var bounds = new OpenLayers.Bounds();
bounds.extend(wrmap.map.getLonLatFromPixel(evt.xy));
var params = {
lang: OpenLayers.Lang.getCode(),
layers: "ch.bafu.wildruhezonen-jagdbanngebiete",
bbox: bounds.toBBOX(),
scale: Math.round(this.map.getScale()/100) * 100,
no_geom: true // no geometry required (faster)
};
Ext.ux.JSONP.request(GeoAdmin.webServicesUrl + "/feature/search",
{
callbackKey: "cb",
params: params,
scope: this,
callback: function(response)
{
var features = format.read(response);
if(features.length > 0)
OpenLayers.Element.addClass(this.map.viewPortDiv,
"cursorPointer");
else
OpenLayers.Element.removeClass(this.map.viewPortDiv,
"cursorPointer");
}
});
}
}
});
mouseHoverControl = new OpenLayers.Control.Hover();
wrmap.map.addControl(mouseHoverControl);
mouseHoverControl.activate();
while this variable and function are set globally:
var hoverTO = false;
function resetHoverTO()
{
hoverTO = false;
}
and this class is added to the css file:
.cursorPointer {
cursor: pointer;
}
An example can be seen on
http://wildruhezonen.ch/test2/wr4_wmts_2.php
(this link might not work for long... these names change all the time)
Have a good time!
Regards, Rolf
> is made regularly in order to check if an object exists. You can usehttp://
api.geo.admin.ch/main/wsgi/doc/build/services/sdiservices.html...
> > > - Zitierten Text anzeigen -- Zitierten Text ausblenden -