iPhone Pinch To Zoom Automatically Pans Afterwars

1,260 views
Skip to first unread message

Sebastian

unread,
May 25, 2011, 4:48:30 PM5/25/11
to Google Maps JavaScript API v3
Hello,
I am using the v3 API of Google maps on my iPhone optimized site
(http://trapped.at, bug is only apparent when using an iPhone).
Whenever I pinch to zoom, the center of the map itself is also
changed. The zooming behavior is correct, but afterwards the center of
the map pans out of the visible area. All sites that use Maps on an
iPhone have this problem, and I have seen few people discuss it, but
no one seems to have a solution for it. I have tried to overcome this
issue with event handlers, but the handlers only fire after the pinch/
pan move is already completed. Help would be greatly appreciated.

Thank you and have a very nice day!

Cheers,
Sebastian

Phil John

unread,
Jun 28, 2011, 7:05:23 AM6/28/11
to Google Maps JavaScript API v3
I have the same problem on the iPod Touch I use for developing.
Panning is OK, but when I pinch to zoom the map starts to load and
then pans. Often, the point I was zooming to gets moved off the
screen.

Is this a recognized problem, or is it some map setting that's not
being set properly?

I notice that the link in @Sebastian's post still exhibits the
problem.

Regards

Phil


On May 25, 9:48 pm, Sebastian <sebas.sc...@googlemail.com> wrote:
> Hello,
> I am using the v3 API of Google maps on myiPhoneoptimized site
> (http://trapped.at, bug is only apparent when using aniPhone).
> Whenever Ipinchto zoom, the center of the map itself is also
> changed. The zooming behavior is correct, but afterwards the center of
> the map pans out of the visible area. All sites that use Maps on aniPhonehave this problem, and I have seen few people discuss it, but

Ben Clayton

unread,
Jun 28, 2011, 11:31:08 AM6/28/11
to google-map...@googlegroups.com
This issue is affecting us also. I've been experimenting with the events listed at http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions
but haven't yet found any kind of fix. If there was any way of making gmaps only accept a single finger pan I reckon the issue would go away.

BTW: A user has also posted this problem on stackoverflow at http://stackoverflow.com/questions/5170572/iphone-google-maps-v3-pans-after-pinch-zoom



JD B.

unread,
Jul 21, 2011, 1:03:05 AM7/21/11
to google-map...@googlegroups.com
If you open http://maps.google.com from an iPhone, pinch does not produce pan. Also zoom in/out is smoother and animated.
Would folks at Google share this javascript implementation?

mirazy

unread,
Jul 28, 2011, 5:15:07 AM7/28/11
to Google Maps JavaScript API v3
http://maps.google.com from iPhone
this is google map v2
not v3
test desktop safari agent change - source view

I'm really hope to fix this problem.

maybe v3 standard of touch move sensitivity is android?
iphone touch is strong sensitivity..

On 7월21일, 오후2시03분, "JD B." <netserve...@gmail.com> wrote:
> If you openhttp://maps.google.comfrom an iPhone, pinch *does not* produce

William

unread,
Jul 28, 2011, 7:59:10 AM7/28/11
to Google Maps JavaScript API v3
On Jul 28, 7:15 pm, mirazy <mir...@gmail.com> wrote:
> maybe v3 standard of touch move sensitivity is android?
> iphone touch is strong sensitivity..
>

I tried it in V3.3, V3.4 and V3.5 and all three versions have this
problem.

However very slow pinch-to-zoom (if you take 5 seconds to make the
gesture) will often work without the pan afterwards. Perhaps this
means that some false behaviour generated from the start of the
gesture is timing out?

Also if you make both fingers touch the phone at exactly the same
time, then pinch-to-zoom, and lift them both off at the same time, it
will not pan.

My guess is that it's something to do with the timing interval
tolerance between detecting a single-touch event and multi-touch, and
not cancelling every event that's generated when the UI still thinks a
single-touch event is beginning.

...

Etienne

unread,
Jul 28, 2011, 8:35:26 AM7/28/11
to Google Maps JavaScript API v3
Well, same problem here...
As there is no zoom_start or zoom_end events i did this :
google.maps.event.addListener(map, 'zoom_changed', function() {
google.maps.event.trigger(map, 'dragend');
});
My goal was to try to end the dragging process that seems to be fired
at the same time as the pinch one.
The fact is that dragend is fired properly but it doesn't affect the
map behavior in anyway

I also tried to disable the draggable attribute of the map on
zoom_changed, and that is not effective because dragstart seems to
have been fired before zoom_changed. Once started, draging process
don't can't be interrupted changing that attribute.

I really afraid that bug can't be bypassed because catchable events
are not precise enough : no zoom-start/zoom-end because zoom is
considered as a punctual event that doesn't fit the pinch action.
Seems that the touch event management of the api consists in
trigerring mouse events...

JD B.

unread,
Jul 28, 2011, 4:46:05 PM7/28/11
to google-map...@googlegroups.com
Maybe at some point call map.draggable=false ?

Etienne Durand

unread,
Jul 28, 2011, 5:24:15 PM7/28/11
to google-map...@googlegroups.com
That was the second solution i tried... That doesn't work because changing the draggable property after the dragstart event occurs and while dragging don't interrupt the dragging process.
That attribute allows the API core to intercepts the dragstart event and prevent it.
The fact is that gmap API allows events to be detected but not prevented : in user's code, returning false when dragstart if fired dont't prevent the dragging process to start.

As info my code was looking like this :
        google.maps.event.addListener(map, 'zoom_changed', function() {
            map.setOptions({draggable:false});
            if(dragLockTimer) window.clearTimeout(dragLockTimer);
            dragLockTimer = setTimeout(function(){ map.setOptions({draggable:true}); },300);
        });
So... Don't waste your time with that solution, it doesn't work

The only solution i still have in mind is really ugly :
Would be something like that (not even tested) :

        var center;
        var zooming = false;
        google.maps.event.addListener(map, 'zoom_changed', function() {
            zooming = true;
            center = map.getCenter();
            if(dragLockTimer) window.clearTimeout(dragLockTimer);
            dragLockTimer = setTimeout(function(){ map.setCenter(center); },100);
        });

William

unread,
Jul 28, 2011, 5:43:49 PM7/28/11
to Google Maps JavaScript API v3
On Jun 28, 9:05 pm, Phil John <pj.appcr...@gmail.com> wrote:
> Is this a recognized problem, or is it some map setting that's not
> being set properly?
>

It's been acknowledged as an "enhancement" (not a bug) in the
following issue:

http://code.google.com/p/gmaps-api-issues/issues/detail?id=3256

so we should star the issue to prioritize work on a fix.

...

Etienne Durand

unread,
Jul 28, 2011, 5:47:05 PM7/28/11
to google-map...@googlegroups.com
I know, i'm the author of that post :o)))))

Le jeudi 28 juillet 2011 23:43:49 UTC+2, William a écrit :

JD B.

unread,
Jul 28, 2011, 6:01:55 PM7/28/11
to google-map...@googlegroups.com
Just voted.
Everyone please vote for it.

Mike W

unread,
Apr 9, 2012, 7:02:01 PM4/9/12
to google-map...@googlegroups.com
I think there's two separate issues I'm hearing.  One has to do with a panning that happens while a pinch/pull is taking place and another is behavior that takes place when a single finger is removed.  I'm having the first issue, but it is not happening on my old iPad running iOS 4.3.5, only on more recent software versions.  Haven't been able to test iOS 5.1 yet.

I've looked for an open issue having to do with this first behavior but couldn't find one.  Does anyone know if this issue has been reported yet?
Reply all
Reply to author
Forward
0 new messages