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

fix map not showing up when first initialized without a height #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rbellens
Copy link

When the map is initialized and the element has no height (clientHeight=0), e.g. when one of the parents are not yet attached, the map will never show up. This is because google maps adds a position: relative to the style of the map element. Calling, the notifyResize will not help in this case. Forcing absolute position, fixes this problem (notifyResize is still needed).

fix map not showing up when first initialized without a height
@ebidel
Copy link
Contributor

ebidel commented Aug 25, 2016

This shouldn't be needed. These styles are within shadow dom.

Can you post a jsbin that repos the issue you're seeing?

@Jookus
Copy link

Jookus commented Sep 20, 2016

In my webapp that commit just solved my problem with two google-map- elements inside of iron-pages. In that case the second element is always loaded without a height and even the functions resize() and notifyResize() do not help. Thank you!

Here is an example for that problem (without the api-code for google-map)
https://plnkr.co/edit/UZF42lzeocb1h0S4xBNM?p=preview

@sebastianroming
Copy link

sebastianroming commented Dec 6, 2016

I have the same problem here. Could we merge and release that?
Also I experience the same problem as @Jookus: The map is loaded after adding !important to the google-map.html file, but it's only shown grey:

google-map-load-error

After resizing (opening Chrome Developer tools is enough), the map is rendered correctly.

I already added the following, but nothing happens:

ready: function() {
    var map = this.$['map-element'];
    map.addEventListener('google-map-ready', function(e) {
        map.notifyResize();
        map.resize();
    });
 }

The event is fired, but nothing happens...

Even when I add a paper-button with onClick event, the map is rendered correctly afterwards:

<paper-button id='btn' on-click='_resizer'>resize</paper-button>
...
_resizer: function() {
    this.$['map-element'].resize();
}

google-map-load-error2

@ebidel
Copy link
Contributor

ebidel commented Dec 25, 2016

There's workarounds posted in #259 (comment) on how to resize the map with iron-pages. One good technique is to wrap <google-map> with a conditional <template is="dom-if"> and make the conditional bound to the select of the map page. That will prevent rendering issues and is also good for perf, since you're delaying the load of the api, the map, etc. on page load.

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

Successfully merging this pull request may close these issues.

5 participants