Map position when re-size

426 views
Skip to first unread message

Jonathan Roque

unread,
Feb 27, 2012, 10:46:59 AM2/27/12
to Google Maps JavaScript API v3
Hi to all.

I'm using the "resize" event to re-size my map when change the div
size. But the question is, the div go to the left size and the all the
map "follow" the div to the left. I'd like to know if and how is
possible to just re-size the div to left side and the map just
increase what is missing in the difference between the old and new
size to the left.

Link to the map:

https://beta.rti4.com.br/c3po/garbage/index.html

Regards,

Jonathan Roque

davie

unread,
Feb 27, 2012, 6:49:25 PM2/27/12
to Google Maps JavaScript API v3
Hi
Try

//Update current center info.
lastCenter=map.getCenter();

new google.maps.event.trigger(map,"resize");

// then add the event listener
google.maps.event.addListener(map, 'resize', function(){
map.setCenter(lastCenter);
});

Regards Davie

Geoff Leff

unread,
Feb 27, 2012, 7:53:37 PM2/27/12
to google-map...@googlegroups.com
Hi Davie,

Thanks for the response..normally I would respond in the group but the post was rejected as it's not the correct group.

Can you advise where in the code your snippet needs to go? I've tried adding it to the bottom of the javascript code but once I drag the marker nothing changes.

Thanks
Geoff

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

davie

unread,
Feb 28, 2012, 5:41:33 AM2/28/12
to Google Maps JavaScript API v3
Hi

If you look at https://beta.rti4.com.br/c3po/garbage/index.html you
will see where the snippet goes


Regards Davie


On Feb 28, 12:53 am, Geoff Leff <webmas...@gleff.com> wrote:
> Hi Davie,
>
> Thanks for the response..normally I would respond in the group but the post was rejected as it's not the correct group.
>
> Can you advise where in the code your snippet needs to go?  I've tried adding it to the bottom of the javascript code but once I drag the marker nothing changes.
>
> Thanks
> Geoff
>

Jonathan Roque

unread,
Feb 28, 2012, 7:04:31 AM2/28/12
to Google Maps JavaScript API v3
Hi Davie,

Thanks for your help. So, what I really want is to change the size
without shaking the map :) If I use getCenter and setCenter the map
will shake to the left and after to the center :). Have you seen the
panel in the map of the maps.google.com? When click in the arrow to
the left, just the panel goes and the map still in the same position
just increasing to the left or this it just a effect?

Regards

Jonathan Roque

Coen de Jong

unread,
Feb 28, 2012, 6:38:09 PM2/28/12
to google-map...@googlegroups.com
What you can do is just to let the map extend behind a floated div that would be your sidebar. I'm pretty sure google does it this way too. So the map doesn't resize, but a part of the map is just hidden from your view. You can do the same. Just show or hide a div that is on top of the map element. The map element stretches behind the div element.

Jonathan Roque

unread,
Feb 28, 2012, 8:27:40 PM2/28/12
to Google Maps JavaScript API v3
Coen de Jong,

I also had this idea today :) but I was trying to find an other way. I
agree with you and think that hide the map behind a div it's the only
way. I'll do this

Thanks,

Jonathan Roque
Reply all
Reply to author
Forward
0 new messages