Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to trigger resize event if map is in tab. #18

Open
ghost opened this issue Aug 8, 2014 · 2 comments
Open

How to trigger resize event if map is in tab. #18

ghost opened this issue Aug 8, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 8, 2014

Hello. There is problem with google maps, that can be resolved triggering resize event.

google.maps.event.trigger(map, 'resize');

But as in your example, addresspicker is creating a google map, so how can I trigger that resize event, I mean what selector i can use as map identifier, to trigger map resize when bootstrap tab is shown ?

This is how map will look like, when boostrap tab is opened:
map-bug

@patrickberger
Copy link

AddressPicker class provides a getter method for inner map object: getGMap(). In case of displaying a map in a Bootstrap modal following snippet did the job.

$('#addresspicker-modal').on('shown.bs.modal', function () {

    var map = addressPicker.getGMap(),
        center = map.getCenter();

    google.maps.event.trigger(map, 'resize');
    map.setCenter(center); 
});

@marioteik
Copy link

What a nice guy. <3 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants