Map Object: 'Click' event not firing when mousemove, rightclick present

444 views
Skip to first unread message

Dave

unread,
Jan 17, 2011, 5:19:35 AM1/17/11
to google-map...@googlegroups.com
I have some code for creating polygon lines which use to work back in June 2010, but does not seem to currently work.  The logic is as follows:

Right click on map to start drawing a polygon, and use the 'mousemove' event to track movement updating the position of the line segment.  Use the "click" event to mark the end of the line segment and start drawing the next line segment.  The 'rightclick' event is used to complete the polygon segment.

The problem I'm having is that the "click" event is only occasionally firing, but the mousemove event is working OK.

I don't have any other event handlers running at the time.

Environment is IE8.0.


geoco...@gmail.com

unread,
Jan 17, 2011, 8:12:39 AM1/17/11
to Google Maps JavaScript API v3
Do you have a link to an example map that shows the problem:
http://groups.google.com/group/google-maps-js-api-v3/t/2b3f101fd509919e

-- Larry

Dave

unread,
Jan 24, 2011, 4:31:41 PM1/24/11
to Google Maps JavaScript API v3
Larry

The code is part of a general polygon editing suite used for creating
and editing polygons interactively.

I have stored an extract of the main logic of the editor at
www.wp196.talktalk.net.

When the code starts, it is expecting the first node to be entered
(using a right click) on the mouse. You should then using a series of
normal "clicks" to define the nodes of the polygon. The polygon shape
follows the mouse movement to assist in creating the polygon. To
complete the polygon, use the "right click" to register the last node.

The editor allows one or more "inner" line segments to be drawn for
holes in the polygon shape.

Issues:
1. Mouse click events are not always triggered. i.e. A new node
is not added to the active line segment.
2. Occassionally, I have noticed the polygon shadding is lost so
that only the polygon line is drawn.


NOTE: This functionally was working in June 2010, so I suspect the
problems may be linked to some recently added functionality /
resolution of event processing; OR code that should never have
worked!!

Regards

Dave

On Jan 17, 1:12 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:

Esa

unread,
Jan 24, 2011, 8:10:15 PM1/24/11
to Google Maps JavaScript API v3
I get an error 'Editor.all is undefined'

Editor seems to be an html element:

Editor = document.getElementById("Line Editor");

Editor.all is handled like an array of html elements:

for (var i = 0; i < Editor.all.length; i++) {
var e = Editor.all[i];
e.style.visibility = (Status ? "visible" : "hidden")
};

I don't think any api version change is causing the problem.

Dave

unread,
Jan 25, 2011, 3:53:28 PM1/25/11
to Google Maps JavaScript API v3
Eva/Larry

The code was working OK with IE. I've now changed the Javascript so
that it now works correctly with Chrome (removing the reference to the
<element>.all field which IE supports, but Chrome does not recognise!)

I suspect the issue is linked to handling a mousemove and click
listener running on the same time on the 'map' object. Are there any
known issues in this area, or has there been any changes in supported
configurations whereby you can have both a "mousemove" and "click"
listener on the map object, or are you allowed to create a "mousemove"
and "click" listener from within a "rightclick" listener.

On Chrome, I now experience the situation where the "mousemove" event
is being triggered correctly, but the "click" listener is never
triggered. On IE 8.0, I do find that occassionally the "click" event
is triggered. Does this point to some timing issues within the API
code whereby the click event is being lost?

Regards

Dave

Rossko

unread,
Jan 25, 2011, 4:57:18 PM1/25/11
to Google Maps JavaScript API v3
> I have stored an extract of the main logic of the editor atwww.wp196.talktalk.net.

Unable to test, fails in FF2 in cVisibility() at
for (var i = 0; i < em.children.length;
where 'em' is an HTML node
.children is not supported in FF2/3.0
http://www.quirksmode.org/dom/w3c_core.html#domtree

Dave

unread,
Jan 25, 2011, 6:31:36 PM1/25/11
to Google Maps JavaScript API v3
Changed the code to make use of childNode and nodeType to resolve the
visibility issues.

I've tested the code with
Chrome 8.0.552.237
Firefox 3.6.13
IE 8.0.6001.18999
Safari 5.0.3 (7533.19.4)

All these browsers show the same effect with event handling (with the
"click" event normally failing to trigger). It does look like a
problem with the Event handling logic within google maps.

With IE, I have noticed that some times when the 'click' event has
fired the resulting polygon shape has got corrupted.

Regards

Dave

Rossko

unread,
Jan 25, 2011, 8:52:15 PM1/25/11
to Google Maps JavaScript API v3
What's going on here in CreatePolygon() ?
var i, p;
...
Polygons[i] = new Array();
'i' is undefined, did you really mean to set Polygons[undefined] to an
empty array? I'm amazed it works at all, but it does seem to.

Observing the mouse cursor when rubber-banding your line is giving a
hint ; sometimes its a grabby hand, sometimes its a pointy finger.
Your line is created 'clickable' by default ; what happens if the user
clicks on your stretchy line? I think you need to set the line
options as non-clickable so that the click gets to the map listener.

Dave

unread,
Jan 26, 2011, 3:58:15 AM1/26/11
to Google Maps JavaScript API v3
Thanks for the information. SOLVED THE PROBLEM

The problem was linked to not explictly setting the "clickable" option
when creating the line even though I had not defined an event listener
for the line.

Regards

Dave
Reply all
Reply to author
Forward
0 new messages