Howto resize the map - smoothly

2,204 views
Skip to first unread message

Pil

unread,
Jan 24, 2013, 4:42:50 AM1/24/13
to Google Maps JavaScript API v3
Please have a look at the well known official Google Maps page and
click the image that says "hide panel' on top of the left panel

http://maps.google.com

The map will be resized to the left border of the browser window while
the right (north-east) bounds of the map won't change. (I'm not
interested in the animation itself here.)

This can also be done the other way round - although probably not so
well known

http://maps.google.com/?hl=iw

In this case if you click the image to hide the right panel, the map
will be resized to the right border of the browser window while the
left (south-west) bounds of the map won't change.

So far so good. Now let's try the same with the Maps API.

http://www.wolfpil.de/v3/east-resize-test.html

This looks good because the map will be resized on the right hand side
while the left (south-east) bounds of the map won't change. So let's
try it the other way round

http://www.wolfpil.de/v3/west-resize-test.html

In this example you'll notice that the map behaviour is completely
different: The map will be resized on the left while the right (north-
east) bounds will be changed!

This is stuttering, jumping behaviour because the center of the map
will also be changed and the map bounds will be extended to the east
although only the west bounds should be extended.

So my question is: How to resize the map smoothly in every case?
~

Andrew Leach

unread,
Jan 24, 2013, 5:17:25 AM1/24/13
to google-map...@googlegroups.com
On 24 January 2013 09:42, Pil <wol...@gmail.com> wrote:
>
> This looks good because the map will be resized on the right hand side
> while the left (south-east) bounds of the map won't change. So let's
> try it the other way round
>
> http://www.wolfpil.de/v3/west-resize-test.html
>
> In this example you'll notice that the map behaviour is completely
> different: The map will be resized on the left while the right (north-
> east) bounds will be changed!
>
> This is stuttering, jumping behaviour because the center of the map
> will also be changed and the map bounds will be extended to the east
> although only the west bounds should be extended.
>
> So my question is: How to resize the map smoothly in every case?

In my copy of Firefox, there is no smooth resizing: it happens all at
once, and the centre point jumps to the left (the middle of the new
size). You may be interested in
http://acleach.me.uk/gmaps/v3/map-offsetcentre.htm which recalculates
the true centre-point [which the API needs] from the apparent
centre-point [where the user is looking as the left edge is moved].
It's not quite the same as yours, but the calculations may be useful.

Pil

unread,
Jan 24, 2013, 7:31:56 AM1/24/13
to google-map...@googlegroups.com
Thanks Andrew.
Ok, I added an animation to one of the examples to resize smoothly

http://www.wolfpil.de/v3/east-ani-resize-test.html

But the problem is that it's not possible to add an animation to the other example because it would look real ugly.

The reason why the other example cannot be made to resize smoothly is that it behaves completely different than the first example.

It's the map itself that behaves somehow right-left reversed - if you know what I mean.

I'm looking for a solution to correct this reversed behaviour.

Pil

unread,
Jan 28, 2013, 7:17:22 AM1/28/13
to Google Maps JavaScript API v3
Seems that this is not possible using the Maps API:
No smooth resizing from right to left - only from left to right.

One more divergence between Maps API and Google Maps.

Enoch Lau (Google Employee)

unread,
Jan 28, 2013, 4:36:14 PM1/28/13
to google-map...@googlegroups.com
Please add a feature request to https://code.google.com/p/gmaps-api-issues/issues/list if you have suggestions on what to add to the API.
Reply all
Reply to author
Forward
0 new messages