Cursor change on MouseOver

999 views
Skip to first unread message

Thomi Pachlatko

unread,
Sep 22, 2011, 11:55:55 AM9/22/11
to GeoAdmin API
Hi
Is it possible to have the cursor changed to a hand if it is over an
area which is integrated by a WMTS layer?
How can it be done?

thanks
Thomi

Moullet Cédric LT

unread,
Sep 23, 2011, 5:12:20 AM9/23/11
to geoadm...@googlegroups.com
Hi,
You can use the feature search service to find features http://api.geo.admin.ch/main/wsgi/doc/build/services/sdiservices.html#feature-search in a bbox. Then you can make an highlight in the map.
Cédric

-----Message d'origine-----
De : geoadm...@googlegroups.com [mailto:geoadm...@googlegroups.com] De la part de Thomi Pachlatko
Envoyé : jeudi, 22. septembre 2011 17:56
À : GeoAdmin API
Objet : Cursor change on MouseOver

Rolf Pachlatko

unread,
Oct 7, 2011, 9:12:01 AM10/7/11
to GeoAdmin API
Hi Cédric!

How do you change the mouse cursor to a hand (css style attribute
cursor:pointer)?
I managed to do this in HTML, but the javascript api overrides my
settings for the map area.

Thanks for your help!

Regards, Rolf



On 23 Sep., 11:12, Moullet Cédric LT <Cedric.Moul...@swisstopo.ch>
wrote:
> Hi,
> You can use the feature search service to find featureshttp://api.geo.admin.ch/main/wsgi/doc/build/services/sdiservices.html...in a bbox. Then you can make an highlight in the map.

Marc Monnerat

unread,
Oct 7, 2011, 11:08:53 AM10/7/11
to geoadm...@googlegroups.com
Hallo Rolf,

With something like this at the end of your style sheet ?

div.olMap {
    cursor: pointer;
}

But I don't get what you mean by over an area which is integrated by a WMTS layer ?
Gruss

Marc 


-- 
-- Τα πάντα ῥεῖ καὶ οὐδὲν μένει

2011/10/7 Rolf Pachlatko <rolf.pa...@gmail.com>

Rolf Pachlatko

unread,
Oct 11, 2011, 5:26:33 PM10/11/11
to GeoAdmin API
Hi Marc

That works, thanks!
What we would actually like to do though is changing the cursor only
when a user is hovering with the pointer over a geometry we've added
through a WMS layer (for example a schutzgebiet).
The user is sometimes confused (as we all know) and therefore it can't
be granted that he realises he is able to click on the geometry and
get a pop up window with information from doing so!

Hope I'm not confusing you with my request! :)

Thanks for your help!
Gruss, Rolf



On 7 Okt., 17:08, Marc Monnerat <procrastina...@gmail.com> wrote:
> Hallo Rolf,
>
> With something like this at the end of your style sheet ?
>
> div.olMap {
>     cursor: pointer;
>
> }
>
> But I don't get what you mean by *over an **area which is integrated by a
> WMTS layer* ?
> Gruss
>
> Marc
>
> --
> -- Τα πάντα ῥεῖ καὶ οὐδὲν μένει
>
> 2011/10/7 Rolf Pachlatko <rolf.pachla...@gmail.com>

Marc Monnerat

unread,
Oct 12, 2011, 1:31:10 PM10/12/11
to geoadm...@googlegroups.com
Hallo Rolf,

No problem with questions, it's actually nice to see people using GeoAdmin!

The image returned by the WMS is not holding any useful information to change the cursor aspect.

It is feasible with WMS GetFeatureInfo, but will be dead slow. A better solution would be using something returning JSON like our feature/search service.
But if I recall, the layers you are interested in are in the BGDI WMS service not in GeoAdmin ?

Gruss

Marc

-- 
-- Τα πάντα ῥεῖ καὶ οὐδὲν μένει

2011/10/11 Rolf Pachlatko <rolf.pa...@gmail.com>

Rolf Pachlatko

unread,
Oct 16, 2011, 7:19:53 PM10/16/11
to GeoAdmin API
Hi Marc

Thanks for your kindness and patience. Yeah, now that you bring it up,
I think I understand about the image and also the dead slow approach
with the getfeatureinfo. But if I call that function for every cursor
position the user is at, it'll generate an insane amount of traffic. I
should probably call the function and retrieve the geometry of every
piece that is shown in the current view of the map, then do the check
locally with the given mouse coordinates and geometry, but that could
be pretty slow, too! especially if I don't use the bounding box but
the real geometry...
Yeah we're using the layers "ch.bafu.wildruhezonen-jagdbanngebiete"
and "ch.bafu.wege-wildruhezonen-jagdbanngebiete", although maybe also
"ch.bafu.bundesinventare-jagdbanngebiete", I would have to check that
with Thomi. What difference does that make? is there no feature search
on these layers? Thanks for answers!

cheers, rolf



On 12 Okt., 19:31, Marc Monnerat <procrastina...@gmail.com> wrote:
> Hallo Rolf,
>
> No problem with questions, it's actually nice to see people using GeoAdmin!
>
> The image returned by the WMS is not holding any useful information to
> change the cursor aspect.
>
> It is feasible with WMS GetFeatureInfo, but will be dead slow. A better
> solution would be using something returning JSON like our
> feature/search<http://api.geo.admin.ch/main/wsgi/doc/build/services/sdiservices.html...>service.
> But if I recall, the layers you are interested in are in the BGDI WMS
> service not in GeoAdmin ?
>
> Gruss
>
> Marc
>
> --
> -- Τα πάντα ῥεῖ καὶ οὐδὲν μένει
>
> 2011/10/11 Rolf Pachlatko <rolf.pachla...@gmail.com>

Rolf Pachlatko

unread,
Oct 25, 2011, 4:58:34 PM10/25/11
to GeoAdmin API
We're actually using these layers as WMTS.
Me personally, I don't see any option how this could possibly be done
in reasonable speed. Can you confirm this or do you have another idea
that might work?

Thanks, Rolf
> > > > > > Thomi- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Cédric Moullet

unread,
Oct 26, 2011, 8:04:56 AM10/26/11
to GeoAdmin API
You can observe in Firebug what happens in map.veloland.ch. A request
is made regularly in order to check if an object exists. You can use
http://api.geo.admin.ch/main/wsgi/doc/build/services/sdiservices.html#feature-search
for that.
There is no standard function in the API for that.
Cédric

Rolf Pachlatko

unread,
Oct 30, 2011, 6:34:10 PM10/30/11
to GeoAdmin API
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



On 26 Okt., 13:04, Cédric Moullet <cedric.moul...@gmail.com> wrote:
> You can observe in Firebug what happens in map.veloland.ch. A request
> 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 -

Marc Monnerat

unread,
Nov 3, 2011, 10:52:03 AM11/3/11
to geoadm...@googlegroups.com
Hello,

So Wildruhezeit is comming.

Very nice... but you better fix the content of your popup.

Marc

2011/10/30 Rolf Pachlatko <rolf.pa...@gmail.com>
Reply all
Reply to author
Forward
0 new messages