Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Use overlayLayer and overlayMouseTarget - #518

Closed
ashleahhill wants to merge 1 commit into
googlemaps:masterfrom
growcode:master
Closed

Use overlayLayer and overlayMouseTarget#518
ashleahhill wants to merge 1 commit into
googlemaps:masterfrom
growcode:master

Conversation

@ashleahhill

Copy link
Copy Markdown

Currently, the lib is drawing the visible target on the overlayMouseTarget layer instead of the overlayLayer. My understanding of how these layers are supposed to work is: visuals on overlay layer, synced, invisible eventTargets on the overlayMouseTarget layer.

I came to this conclusion by picking apart the default map markers and this documentation: https://developers.google.com/maps/documentation/javascript/reference/overlay-view#MapPanes

With this setup, the z-index logic can remain simple and the clusters will continue to show up over pins but under other UI.

fixes #506

@googlebot

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Oct 7, 2019
this.div_ = document.createElement("div");
this.div_.className = this.className_;
this.eventDiv_ = this.div_.cloneNode();
this.eventDiv_.className += ' event';

@garylittleRLP garylittleRLP Oct 7, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for adding the "event" class name to the overlayMouseTarget div? Shouldn't it be exactly the same class as the overlayLayer div?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a way to differentiate the visible div, div.classname and the event div, div.classname.event . The same class configured by the user is on both divs, but event is added so that you can use a :not or other selector.

I guess I could use a more BEM friendly div.classname.div.classname--event if you'd prefer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two divs should be absolutely identical, so I think it's best if the overlayMouseTarget div has exactly the same class as the overlayLayer div.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +302 to +304
this.syncDivStyle({
title: this.div_.title,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you have to synch the display style as well?

@ashleahhill ashleahhill Oct 7, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was only to set the props that the code sets on the visible div. Line 388 copies all of the css set on this.div_

Edit: for grammar, typo

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -286,6 +298,10 @@ ClusterIcon.prototype.show = function () {
this.div_.title = this.sums_.title;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just before this line you should also be setting the innerHTML of the overlayMouseTarget div to the same as that of the overlayLayer div. This ensures the overlayMouseTarget div has exactly the same size as the overlayLayer div.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't copying the height and width from the overlayDiv work without duplicating innerHTML?

I'm open to setting it and adding opacity: 0 to line 388; it just seems unnecessary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just being cautious.

@ashleahhill ashleahhill Oct 16, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syncing innerHTML to event div and setting opacity when css is updated (in syncDivStyle method)

*/
ClusterIcon.prototype.syncDivStyle = function (vars) {
if (vars) {
Object.assign(this.eventDiv_, vars);

@ashleahhill ashleahhill Oct 7, 2019

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is used to sync any other DOMElement props outside of CSS. The only property I found that needed this was the title.

@ashleahhill

Copy link
Copy Markdown
Author

@googlebot I signed it!

1 similar comment
@ashleahhill

Copy link
Copy Markdown
Author

@googlebot I signed it!

@googlebot

Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Oct 7, 2019
Object.assign(this.eventDiv_, vars);
}
if (this.eventDiv_ && this.div_) {
this.eventDiv_.style.cssText = this.div_.style.cssText;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overlayDiv, this.div_, is positioned and resized using CSS. By copying the cssText we copy the same height, width, z-index, etc. without having to specify each.

@ashleahhill

Copy link
Copy Markdown
Author

I noticed that there's a big ES6 rewrite happening. Is this fix still necessary?

@jpoehnelt

Copy link
Copy Markdown

@ashleahhill I'm not sure when I will get to rewriting this one. I'll defer to @garylittleRLP for the comments already made here.

@ashleahhill

Copy link
Copy Markdown
Author

I'm also fine with rebasing this off of the 3.0 work or opening another PR for 3.0.

@jpoehnelt jpoehnelt mentioned this pull request Oct 30, 2019
@jpoehnelt

Copy link
Copy Markdown

closing in favor of #558

@jpoehnelt jpoehnelt closed this Oct 30, 2019
@jpoehnelt

Copy link
Copy Markdown

@ashleahhill see #558 (comment) to consent to your commit being merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zIndex for @google/markerclusterer icons is too large

4 participants