Clicks to InfoBox passed through to map on Safari on iPad

306 views
Skip to first unread message

GeoffSchultz

unread,
Dec 8, 2011, 1:22:50 PM12/8/11
to google-maps-utility-library-v3
On an iPad running Safari & iOS 5.0.1, clicks to an InfoBox are passed
through to the map and aren't received by the InfoBox. The [X] close
box doesn't work either.

See http://www.geoffschultz.org/Test/infobox.html

Click on the map to create an InfoBox at the cursor.

Note that this works properly on Safari on Windows 7, FireFox, IE and
Chrome.

-- Geoff

Gary Little

unread,
Dec 9, 2011, 11:09:19 AM12/9/11
to google-maps-utility-library-v3
Geoff,

Thanks for the heads up. This used to work as expected on the iPad,
but a change in iOS seems to have affected the behavior. Have you
tried on Android?

Gary

On Dec 8, 10:22 am, GeoffSchultz <geoffrey.w.schu...@gmail.com> wrote:
> On an iPad running Safari & iOS 5.0.1, clicks to an InfoBox are passed
> through to the map and aren't received by the InfoBox.  The [X] close
> box doesn't work either.
>

> Seehttp://www.geoffschultz.org/Test/infobox.html

Gary Little

unread,
Dec 9, 2011, 11:42:50 AM12/9/11
to google-maps-utility-library-v3
Actually, I was wrong -- InfoBox has never been able to control event
propagation on iPhone (or iPad) as it can on other devices. (If anyone
knows how to control this, I'd be pleased to hear how.) So a click
anywhere in the InfoBox will pass through to the map layer. If you
don't have a click handler attached to the map, however, you probably
won't notice.

GeoffSchultz

unread,
Dec 10, 2011, 2:25:43 PM12/10/11
to google-maps-utility-library-v3
My issue is that I have forms which are displayed within the InfoBox
and none of the checkboxes, buttons, [X] and other items work. As it
turns out, I do have a click handler on the map. If you want to see
how I'm probably using InfoBoxes in ways that you never imagined, you
can look at http://www.geoffschultz.org/weather_map in particular
select "grib".

-- Geoff

P.S. I don't have any Android devices.

Gary Little

unread,
Dec 11, 2011, 12:39:07 PM12/11/11
to google-maps-utility-library-v3
Geoff,

I have a similar problem on my real estate map on the iPhone but I've
worked around it by eliminating a map click handler that closes the
InfoBox (so you have to close it by clicking the close box). It's not
perfect since you can click markers underneath the InfoBox.

I'm not sure if this is a bug in iOS/Safari, the Maps API, or what.
The technique I use to prevent the event propagation works with all
others browsers I'm aware of.

Gary

On Dec 10, 11:25 am, GeoffSchultz <geoffrey.w.schu...@gmail.com>
wrote:


> My issue is that I have forms which are displayed within the InfoBox
> and none of the checkboxes, buttons, [X] and other items work.  As it
> turns out, I do have a click handler on the map.  If you want to see
> how I'm probably using InfoBoxes in ways that you never imagined, you

> can look athttp://www.geoffschultz.org/weather_mapin particular

GeoffSchultz

unread,
Dec 12, 2011, 8:18:48 AM12/12/11
to google-maps-utility-library-v3
Gary,

I use the same technique which handles most of my FYI InfoBoxes where
a click received to the map closes it. Unfortunately I'm using an
InfoBox with a form with checkboxes, dropdowns and a variety of
buttons, and none of that works. Maybe I'll just explore a different
InfoSomething to use.

I've looked at your code and there's click/close event handler code
that I really don't understand. Where the heck does "e" come from in
these functions? I'm an ex-operating systems guy, but a newbie/hacker
when it comes to JS. Unfortunately I have no idea as how to debug JS
on on iPad...

-- Geoff

Gary Little

unread,
Dec 13, 2011, 6:45:33 PM12/13/11
to google-maps-utility-library-v3
"e" is the event object that is passed to DOM event listeners.

GeoffSchultz

unread,
Dec 14, 2011, 4:21:10 PM12/14/11
to google-maps-utility-library-v3
I was at the mall today and tried it on an Android based tablet and it
doesn't work there either.

-- Geoff

GeoffSchultz

unread,
Dec 17, 2011, 11:29:25 AM12/17/11
to google-maps-utility-library-v3
I just figured it out! You need to make the pane
"overlayMouseTarget".

-- Geoff

GeoffSchultz

unread,
Dec 17, 2011, 11:34:03 AM12/17/11
to google-maps-utility-library-v3
Sorry, I was wrong...this didn't fix it. Stupid me checked it on
Safari on the PC & not on the iPad...Duh!

On Dec 17, 11:29 am, GeoffSchultz <geoffrey.w.schu...@gmail.com>
wrote:

GeoffSchultz

unread,
Dec 17, 2011, 4:51:46 PM12/17/11
to google-maps-utility-library-v3
Gary,

I checked InfoBubble on the iPad and found that it works as expected.
Here's the code that the use to handle events:

/**
* Add events to stop propagation
* @private
*/
InfoBubble.prototype.addEvents_ = function() {
// We want to cancel all the events so they do not go to the map
var events = ['mousedown', 'mousemove', 'mouseover', 'mouseout',
'mouseup',
'mousewheel', 'DOMMouseScroll', 'touchstart', 'touchend',
'touchmove',
'dblclick', 'contextmenu', 'click'];

var bubble = this.bubble_;
this.listeners_ = [];
for (var i = 0, event; event = events[i]; i++) {
this.listeners_.push(
google.maps.event.addDomListener(bubble, event, function(e) {
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
})
);
}
};

GeoffSchultz

unread,
Dec 18, 2011, 9:09:24 AM12/18/11
to google-maps-utility-library-v3
I modified InfoBox.js code to basically mimic the InfoBubble code and
everything now functions as expected on an iPad.

I must admit that I don't understand why your code and the InfoBubble
code saves the handlers and removes them before doing a setMap(null)
on the InfoBox. According to what I've read elsewhere (and from a
Google employee), all of the listeners associated with an object are
removed when the setMap(null) is done. It seems like this just
duplicates that functionality.

Anyhow, I'm a happy camper. If/when you update your code to handle
this, I'll be glad to pull an "official" version down so that I stay
on track.

-- Geoff

Gary Little

unread,
Dec 19, 2011, 4:07:29 AM12/19/11
to google-maps-utility-library-v3
Geoff,

Send me your modified file so I can see exactly what changes you made.

Gary

Gary Little

unread,
Dec 20, 2011, 12:22:38 PM12/20/11
to google-maps-utility-library-v3
The new trunk version of InfoBox should fix your issues. I'll tag it
in a few days.

Gary

Reply all
Reply to author
Forward
0 new messages