iPhone problem: how do you get map to pan when the drag begins in a floatPane DIV?

94 views
Skip to first unread message

Gary Little

unread,
Jan 21, 2010, 5:51:27 PM1/21/10
to Google Maps JavaScript API v3
I've got a problem relating to the iPhone I'm trying to solve. I've
written a class called InfoBox ( see
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
) which can be used to place a DIV box on the floatPane of a map.

I've put in code to (conditionally) allow mouse events originating in
the InfoBox to be passed on to the map -- this means that, for most
browsers, the map will pan when you drag even if the drag starts
inside the InfoBox.

Unfortunately, this technique does not work when using Safari on the
iPhone. Instead, when you drag, the whole browser window moves -- this
is the usual behaviour when you try to drag an iPhone browser window.

Does anyone know how to override this iPhone behavior so that the map
will pan instead? Map applications built with Apple's Map Kit do work
the way I want but, of course, they're not created using the
JavaScript API.

Gary

Ben Appleton

unread,
Jan 21, 2010, 6:11:49 PM1/21/10
to google-map...@googlegroups.com
Hi Gary,

Do you cancel the default behavior on the drag event in the floatPane?
eg. using the following function:

function cancelDefault(e) {
e.returnValue = false;
e.preventDefault && e.preventDefault();
}

Cheers
Ben

> --
> 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.
>

Gary Little

unread,
Jan 21, 2010, 9:27:52 PM1/21/10
to Google Maps JavaScript API v3
I've tried calling preventDefault() for touchstart, touchend,
touchmove events thinking they would then be passed on to the map,
causing the map to pan. This doesn't work: the map window doesn't move
(good), but the map doesn't pan (bad).

Gary

On Jan 21, 3:11 pm, Ben Appleton <apple...@google.com> wrote:
> Hi Gary,
>
> Do you cancel the default behavior on the drag event in the floatPane?
>  eg. using the following function:
>
> function cancelDefault(e) {
>   e.returnValue = false;
>   e.preventDefault && e.preventDefault();
>
> }
>
> Cheers
> Ben
>
>
>
> On Fri, Jan 22, 2010 at 9:51 AM, Gary Little <g...@luxcentral.com> wrote:
>
> > I've got a problem relating to the iPhone I'm trying to solve. I've
> > written a class called InfoBox ( see

> >http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobo...

Ben Appleton

unread,
Jan 22, 2010, 12:51:33 AM1/22/10
to google-map...@googlegroups.com
Oh I'm sorry: we suppress drag events in the floatPane, as this is where we place the info window.

Gary Little

unread,
Jan 22, 2010, 11:02:10 AM1/22/10
to Google Maps JavaScript API v3
As I said earlier, it is possible to drag the map even if the drag
starts in a floatPane object -- at least if you're using a Mac OS X or
Windows browsers. You have to be using a class like InfoBox that lets
you turn this capability on or off. (google.maps.InfoWindow always
turns the capability off -- it never passes mouse events on to the
map.) The only situation I've found where the InfoBox drag isn't
handled by the map is on iPhone (haven't tried Android). Apples'
event handlers seems to be getting in the way somehow.

Gary

On Jan 21, 9:51 pm, Ben Appleton <apple...@google.com> wrote:
> Oh I'm sorry: we suppress drag events in the floatPane, as this is where we

> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>


> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > --
> > 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<google-maps-js-api-v3%2B unsub...@googlegroups.com>

Gary Little

unread,
Feb 1, 2010, 2:12:44 AM2/1/10
to Google Maps JavaScript API v3
... does anyone have any idea of how to get the functionality I'm
looking for on the iPhone using the JavaScript API? Is it even
possible? On a small screen like iPhone/Android it would be very handy
to be able to pan the map when the pan gesture begins in a floatPane
div.

Gary

Reply all
Reply to author
Forward
0 new messages