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

Use overlayLayer and overlayMouseTarget #518

Closed
wants to merge 1 commit into from

Conversation

ashleahhill
Copy link

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

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
@@ -120,31 +121,37 @@ ClusterIcon.prototype.onAdd = function () {

this.div_ = document.createElement("div");
this.div_.className = this.className_;
this.eventDiv_ = this.div_.cloneNode();
this.eventDiv_.className += ' event';
Copy link
Contributor

@garylittleRLP garylittleRLP Oct 7, 2019

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

Copy link
Author

@ashleahhill ashleahhill Oct 7, 2019

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

Copy link
Author

@ashleahhill ashleahhill Oct 16, 2019

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);
Copy link
Author

@ashleahhill ashleahhill Oct 7, 2019

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
Author

@googlebot I signed it!

1 similar comment
@ashleahhill
Copy link
Author

@googlebot I signed it!

@googlebot
Copy link

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

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

@jpoehnelt
Copy link
Contributor

@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
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
Contributor

closing in favor of #558

@jpoehnelt jpoehnelt closed this Oct 30, 2019
@jpoehnelt
Copy link
Contributor

@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