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.