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

google-map does not render to its size when used in core-animated-pages when it is in secion 1+ #33

Closed
tobiashutterer opened this issue Jul 15, 2014 · 19 comments
Labels

Comments

@tobiashutterer
Copy link

using in a just works right on index=0. When i try using or styling it on index 1-x the box is as i defined it, but the redered map just shows about 200px in the left upper corner of the map box.
.
Might this me a bug, or am I too stupid? I hope it is the second one.

image

@bamnet
Copy link
Contributor

bamnet commented Jul 15, 2014

Can you link to a sample which reproduces this?

@ebidel
Copy link
Contributor

ebidel commented Jul 15, 2014

I believe the problem is related to the fact that the map's container is display: none initially. From here, the fix is:

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

Haven't tested, but we can bake something like this into the map element.

@ebidel
Copy link
Contributor

ebidel commented Jul 16, 2014

Unfortunately, there's no good way to detect when the parent element of the map becomes visible. I got it working by polling if .offsetParent was set using rAF callbacks, but that's not ideal. If core-animated-pages were to fire an event, the client can call mapEl.resize() to ensure the map is displayed properly. That method already has the google.maps.event.trigger(map, 'resize'); trick.

In the general case, mapEl.resize() will adjust the map to display properly.

@sjmiles
Copy link
Contributor

sjmiles commented Jul 16, 2014

Fwiw, this is a common problem and we need to work out a way to inform downstream elements of these kind of changes. I'm reluctant to get into broadcasting, but I don't have any better ideas at the moment.

@addyosmani
Copy link
Member

Are there perf implications of excessive broadcasting you're concerned of?

@ebidel
Copy link
Contributor

ebidel commented Jul 16, 2014

We almost need a platform primitive to know if an element is in the render tree.

@ebidel
Copy link
Contributor

ebidel commented Jul 16, 2014

core-animated-pages now fires the "core-animated-pages-transition-prepare" event when transitions occur: googlearchive/core-animated-pages@e18d5bf

This should do the trick:

animatedPagesEl.addEventListener('core-animated-pages-transition-prepare', function() {
  mapsEl.resize();
});

@ebidel
Copy link
Contributor

ebidel commented Jul 30, 2014

@tobiashutterer we moved this to the GoogleWebComponents org and will be keeping the release version up to date more frequently. You'll get the latest when using the plain bower install GoogleWebComponents/google-map.

Closing this as the workaround is posted above for the original issue.

@phidias51
Copy link

I've noticed the same problem when embedding the map in a core-pages element or a core-collapse element. It looks like the map is being translated up and to the left, leaving grey space behind in its wake. The position is not centered in the middle of the map. Also, the map.resize() call is causing the original lat/longs to be shifted.

@Zippersk
Copy link

I have same problem with neon-animated-pages. I can't find som fire like neon-animated-pages-transition-prepare. Is there any solution to display map?

@atotic
Copy link
Contributor

atotic commented Jun 15, 2015

Pull #152 should have fixed this for neon-animated-pages. Have you tried #master

@Zippersk
Copy link

Install master verison helps! Thaks a lot. :)

@kingflurkel
Copy link

I still have this bug with neon-animated-pages.
I use this version: "google-map": "GoogleWebComponents/google-map#^1.0.0",
Any help / tips to get this working?

@atotic
Copy link
Contributor

atotic commented Jul 9, 2015

@kingflurkel if you have a test case, I can take a look

@kingflurkel
Copy link

EDIT / removed link to very unfinished work

@atotic
Copy link
Contributor

atotic commented Jul 9, 2015

Thanks.
google-map is not getting the iron-resize event. I'll have to dig in to
find out why.

On Thu, Jul 9, 2015 at 11:08 AM, Michael Thuy notifications@github.com
wrote:

http://actaanbod.bitballoon.com/
Click on the location icon. So I have google-map within
iron-animated-pages.
Code:

https://github.com/A-StadLabs/activiteitenaanbod/tree/master/app/elements/a-activiteitenstage

https://github.com/A-StadLabs/activiteitenaanbod/blob/master/app/elements/a-locatie/a-locatie.html


Reply to this email directly or view it on GitHub
#33 (comment)
.

@kingflurkel
Copy link

Maybe because google-map is in another custom-element, which is in iron-pages?

@atotic
Copy link
Contributor

atotic commented Jul 9, 2015

The problem is in the neon-animated-pages. Because map is inside a custom element, it does not get a notification that it has been shown. Iniside neon-animated-pages:

      this.resizerShouldNotify = function(element) {
        return element == selectedPage;
      }
      this.notifyResize();

This should probably be: if element is selectedPage, or its parent is a selected page.

@atotic
Copy link
Contributor

atotic commented Jul 9, 2015

This issue was moved to PolymerElements/neon-animation#57

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

No branches or pull requests

9 participants