Optimised Markers consume the Map mousemove event

666 views
Skip to first unread message

Martin™

unread,
Oct 16, 2011, 2:25:34 AM10/16/11
to Google Maps JavaScript API v3
Hi All.

I've started a new thread for this subject - it follows on from this
recent thread about MarkerImage and optimised Markers:

https://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/ac0d90c91ecec6a0/51a0cc033dba3866?hl=en#51a0cc033dba3866

I've run into a problem with optimised Markers and the Map mousemove
event...

Here's a project i've been working on:

http://developer.martinpearman.co.uk/markers_event_layer/demo/index.htm

and

http://developer.martinpearman.co.uk/markers_event_layer/demo/index.htm?eventtype=click

I'm detecting click OR mouseover and mouseout events on all markers
under the mouse - not just the top most marker.
My first link is the mouseover and mouseout version, my second link
the click version.

Markers consume the Map click event so my single Map click event
listener detects no Marker clicks unless you set the MarkerOption
clickable to false.
My code does this and it works as desired except i'd like the cursor
to change when over a Marker - that doesn't happen when the
MarkerOption clickable is false.
http://code.google.com/apis/maps/documentation/javascript/reference.html#MarkerOptions

Anyway that demo defines a MarkerImage with a scaledSize set to the
same size as the MarkerImage's size.
If you read the thread i linked to you'll find that setting a
MarkerImage scaledSize forces non-optimised Markers.
So i changed my demo to pass null as scaledSize in the MarkerImage
connstructor and thought that would give me optimised Markers and my
existing code would still work but it doesn't.

Optimised Markers by default consume the Map mousemove event so my
demo's mousemove event listener never executes.
Much like the demo's click event listener never executes unless the
MarkerOption clickable is set to false.
(Non-optimised Markers with MarkerOption clickable set to true
(default) do NOT consume the Map mousemove event).

Setting an optimised Marker's MarkerOption clickable to false stops
the Marker from consuming the Map mousemove event and my code again
works as desired - albeit with no change of cursor when over a Marker.

Here's a simple map that demonstrates this behavior:

http://developer.martinpearman.co.uk/markers_event_layer/mousemove_event/mousemove_event.htm

On that map, Markers are optimised and clickable - both these options
are the defaults.
Move the mouse over a group of Markers and you'll see the Map
mousemove event listener stops updating the mouse position top center
of map.

http://developer.martinpearman.co.uk/markers_event_layer/mousemove_event/mousemove_event.htm?optimized=0

That map uses non-optimised Markers that are clickable by default and
the Map mousemove event listeners executes even when the mouse is over
one or more Markers.

http://developer.martinpearman.co.uk/markers_event_layer/mousemove_event/mousemove_event.htm?clickable=0

Markers on this map are optimised but NOT clickable and the Map
mousemove event listener executes as desired.

The documentation for Map events points out that the Map click event
does NOT fire when a Marker is clicked on (it doesn't mention
MarkerOption clickable), but doesn't mention that the Map mousemove
event does not fire when the mouse is over an optimised Marker.

So my question - is this a bug or the intended behavior?

For my project i can set the MarkerOption clickable to false so BOTH
my Map click and Map mousemove event listeners execute as desired and
it will work.
But i'd rather that at least with the Map mousemove event i can leave
clickable set to true so that the mouse icon changes to a pointer when
over a Marker.

Thanks for reading my long(ish) post!

Martin.

Chris Broadfoot

unread,
Oct 17, 2011, 11:25:43 AM10/17/11
to google-map...@googlegroups.com
Hi Martin,

This does indeed look like a bug. The only point of contention is whether the bug lies with optimized markers, or unoptimized markers. In reality, "clickable" (default true) means that the overlay (marker, polygon, polyline) captures all mouse events.

I'll raise this issue with the team.

Thanks,
Chris

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Martin™

unread,
Oct 18, 2011, 2:41:42 AM10/18/11
to Google Maps JavaScript API v3
Thanks.

I'd ideally like to see the Map click event behave as it did in v2 of
the API.

http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMap2.click

So a click on an Overlay triggers both a Map and and an Overlay click
event.

I've seen posts on this group requesting the same - generally to
enable some sort of event delegation when dealing with lots of
Markers.

Think about DOM event listeners - you can listen for a click event on
an element and also any element that it contains.
Much more flexible then just a single element being able to generate
an event.

Martin.


On Oct 17, 4:25 pm, Chris Broadfoot <c...@google.com> wrote:
> Hi Martin,
>
> This does indeed look like a bug. The only point of contention is whether
> the bug lies with optimized markers, or unoptimized markers. In reality,
> "clickable" (default true) means that the overlay (marker, polygon,
> polyline) captures all mouse events.
>
> I'll raise this issue with the team.
>
> Thanks,
> Chris
>
> --http://twitter.com/broady
>
>
>
>
>
>
>
> On Sun, Oct 16, 2011 at 5:25 PM, Martin™ <warwo...@gmail.com> wrote:
> > Hi All.
>
> > I've started a new thread for this subject - it follows on from this
> > recent thread about MarkerImage and optimised Markers:
>
> >https://groups.google.com/group/google-maps-js-api-v3/browse_frm/thre...
>
> > I've run into a problem with optimised Markers and the Map mousemove
> > event...
>
> > Here's a project i've been working on:
>
> >http://developer.martinpearman.co.uk/markers_event_layer/demo/index.htm
>
> > and
>
> >http://developer.martinpearman.co.uk/markers_event_layer/demo/index.h...
>
> > I'm detecting click OR mouseover and mouseout events on all markers
> > under the mouse - not just the top most marker.
> > My first link is the mouseover and mouseout version, my second link
> > the click version.
>
> > Markers consume the Map click event so my single Map click event
> > listener detects no Marker clicks unless you set the MarkerOption
> > clickable to false.
> > My code does this and it works as desired except i'd like the cursor
> > to change when over a Marker - that doesn't happen when the
> > MarkerOption clickable is false.
>
> >http://code.google.com/apis/maps/documentation/javascript/reference.h...
>
> > Anyway that demo defines a MarkerImage with a scaledSize set to the
> > same size as the MarkerImage's size.
> > If you read the thread i linked to you'll find that setting a
> > MarkerImage scaledSize forces non-optimised Markers.
> > So i changed my demo to pass null as scaledSize in the MarkerImage
> > connstructor and thought that would give me optimised Markers and my
> > existing code would still work but it doesn't.
>
> > Optimised Markers by default consume the Map mousemove event so my
> > demo's mousemove event listener never executes.
> > Much like the demo's click event listener never executes unless the
> > MarkerOption clickable is set to false.
> > (Non-optimised Markers with MarkerOption clickable set to true
> > (default) do NOT consume the Map mousemove event).
>
> > Setting an optimised Marker's MarkerOption clickable to false stops
> > the Marker from consuming the Map mousemove event and my code again
> > works as desired - albeit with no change of cursor when over a Marker.
>
> > Here's a simple map that demonstrates this behavior:
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...
>
> > On that map, Markers are optimised and clickable - both these options
> > are the defaults.
> > Move the mouse over a group of Markers and you'll see the Map
> > mousemove event listener stops updating the mouse position top center
> > of map.
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...
>
> > That map uses non-optimised Markers that are clickable by default and
> > the Map mousemove event listeners executes even when the mouse is over
> > one or more Markers.
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...

Martin™

unread,
Oct 27, 2011, 12:32:57 AM10/27/11
to Google Maps JavaScript API v3
Hi Chris.

Is there any news on this issue yet?

Thanks.

Martin.


On Oct 17, 4:25 pm, Chris Broadfoot <c...@google.com> wrote:
> Hi Martin,
>
> This does indeed look like a bug. The only point of contention is whether
> the bug lies with optimized markers, or unoptimized markers. In reality,
> "clickable" (default true) means that the overlay (marker, polygon,
> polyline) captures all mouse events.
>
> I'll raise this issue with the team.
>
> Thanks,
> Chris
>
> --http://twitter.com/broady
>
>
>
>
>
>
>
> On Sun, Oct 16, 2011 at 5:25 PM, Martin™ <warwo...@gmail.com> wrote:
> > Hi All.
>
> > I've started a new thread for this subject - it follows on from this
> > recent thread about MarkerImage and optimised Markers:
>
> >https://groups.google.com/group/google-maps-js-api-v3/browse_frm/thre...
>
> > I've run into a problem with optimised Markers and the Map mousemove
> > event...
>
> > Here's a project i've been working on:
>
> >http://developer.martinpearman.co.uk/markers_event_layer/demo/index.htm
>
> > and
>
> >http://developer.martinpearman.co.uk/markers_event_layer/demo/index.h...
>
> > I'm detecting click OR mouseover and mouseout events on all markers
> > under the mouse - not just the top most marker.
> > My first link is the mouseover and mouseout version, my second link
> > the click version.
>
> > Markers consume the Map click event so my single Map click event
> > listener detects no Marker clicks unless you set the MarkerOption
> > clickable to false.
> > My code does this and it works as desired except i'd like the cursor
> > to change when over a Marker - that doesn't happen when the
> > MarkerOption clickable is false.
>
> >http://code.google.com/apis/maps/documentation/javascript/reference.h...
>
> > Anyway that demo defines a MarkerImage with a scaledSize set to the
> > same size as the MarkerImage's size.
> > If you read the thread i linked to you'll find that setting a
> > MarkerImage scaledSize forces non-optimised Markers.
> > So i changed my demo to pass null as scaledSize in the MarkerImage
> > connstructor and thought that would give me optimised Markers and my
> > existing code would still work but it doesn't.
>
> > Optimised Markers by default consume the Map mousemove event so my
> > demo's mousemove event listener never executes.
> > Much like the demo's click event listener never executes unless the
> > MarkerOption clickable is set to false.
> > (Non-optimised Markers with MarkerOption clickable set to true
> > (default) do NOT consume the Map mousemove event).
>
> > Setting an optimised Marker's MarkerOption clickable to false stops
> > the Marker from consuming the Map mousemove event and my code again
> > works as desired - albeit with no change of cursor when over a Marker.
>
> > Here's a simple map that demonstrates this behavior:
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...
>
> > On that map, Markers are optimised and clickable - both these options
> > are the defaults.
> > Move the mouse over a group of Markers and you'll see the Map
> > mousemove event listener stops updating the mouse position top center
> > of map.
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...
>
> > That map uses non-optimised Markers that are clickable by default and
> > the Map mousemove event listeners executes even when the mouse is over
> > one or more Markers.
>
> >http://developer.martinpearman.co.uk/markers_event_layer/mousemove_ev...

Andre Tannus

unread,
May 2, 2013, 4:38:59 PM5/2/13
to google-map...@googlegroups.com
Damn entangled Schrodinger markers... Did this get sucked into a black hole?

I do some digging every now and then for a fix for this, because it causes some annoying issues on my map apps.
I have worked around it by de-optimizing the icons when I need to capture mousemove over them, but that terrible usability implications.

I have also given this some thought, and I'm wondering if the absence of the mousemove event could be related to the very fact the markers are optimized.
If that is the case, it would be nice to know for sure, so we could quit waiting around and/or find an acceptable workaround on our own.

It is either a bug or not, but right now it is in an entangled state.
Shall we open the box and shine an photon on it?

Andre
Reply all
Reply to author
Forward
0 new messages