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

Offset tooltip popup so it fits inside the map bounds #9819

Closed

Conversation

JacobBrandt
Copy link
Contributor

Fixes #8799

screen shot 2017-01-10 at 12 37 34 pm
screen shot 2017-01-10 at 12 37 19 pm

@elasticmachine
Copy link
Contributor

Can one of the admins verify this patch?

@thomasneirynck
Copy link
Contributor

jenkins, test this

@thomasneirynck thomasneirynck added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review labels Jan 10, 2017
@JacobBrandt
Copy link
Contributor Author

Anyone else think that the tooltip display of the features geometry coordinates as an object is hard to read?

I think I like this better.
screen shot 2017-01-10 at 5 41 40 pm

Would it be OK to add this change in as well or create another issue?

@thomasneirynck
Copy link
Contributor

@JacobBrandt the new info-box is more crisp, you're right. afaic, it's fine to add that to this PR.

@karmi
Copy link

karmi commented Jan 25, 2017

Hi @JacobBrandt, we have found your signature in our records, but it seems like you have signed with a different e-mail than the one used in yout Git commit. Can you please add both of these e-mails into your Github profile (they can be hidden), so we can match your e-mails to your Github profile?

@JacobBrandt
Copy link
Contributor Author

@karmi I re-signed with my current e-mail. I no longer have the other one used in the commit.

@JacobBrandt JacobBrandt force-pushed the tilemap_tooltips_cutoff_master branch from e35c20d to 7924e45 Compare January 25, 2017 21:31
Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

thanks @JacobBrandt

I like the improvement to the label contents and we should merge those in IMO.

I don't think we should apply this fix this way though. For a few reasons:

  • we have to rely on a clever trick to measure the balloon contents
  • we have to rely on implementation details of Leaflet to retrieve the DOM-node and then measure it.
  • we also need to couple styling info from our CSS so we can do the offsets appropriately (the 16 pixels).

IMHO, keeping a tooltip inside the map is an upstream issue with Leaflet, and it should be addressed there. I understand this work-around does add value to Kibana, but what we're really doing is patching some Leaflet limitations inside Kibana. There are other places in Kibana where we depend on 'hacks' to achieve some desired effect (e.g. desaturating the map colors), but those shouldn't really have sneaked in there to begin with. So we should avoid this going forward.

If you're interested to work further on this, I would take out the re-positioning logic for the tooltip, and just keep the improvement to the contents.

lat: feature.geometry.coordinates[1],
lon: feature.geometry.coordinates[0]
})
label: 'Latitude',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an improvement. Crisper and more legible.

const popupDistanceToRightEdge = Math.abs(latLng.lng - east) * xscale;
let widthOffset = 0;
if (popupDistanceToLeftEdge < popupWidth / 2) {
widthOffset = popupWidth / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

for the pop-up to attach to the point, we'd probably want:
widthOffset = popupWidth / 4 + 16;

image

Similar for right side:
widthOffset = -popupWidth / 4 - 16;


// We need to create the popup first to determine how tall it will be. Give
// it an out of map bounds offset as we don't want to see this one. It will
// get replaced on the next popup creation where we apply the correct offset
Copy link
Contributor

@thomasneirynck thomasneirynck Feb 7, 2017

Choose a reason for hiding this comment

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

clever approach!

.setLatLng(latLng)
.setContent(content)
.openOn(this.map);
const popupHeight = popup._contentNode.clientHeight;
Copy link
Contributor

@thomasneirynck thomasneirynck Feb 7, 2017

Choose a reason for hiding this comment

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

We probably shouldn't introduce dependencies on internal implementation details of 3rd party libraries.

@JacobBrandt
Copy link
Contributor Author

JacobBrandt commented Feb 8, 2017

@thomasneirynck Yea I see what your saying. I did have to rely on knowing some inner workings of Leaflet which I wasn't really a fan of. Although I do question that if this is really an upstream Leaflet issue (which I do think it is, don't get me wrong) than why was the issue #8799 given bug and P3 labels and then also referenced by other issues for instance #8944? I'd rather not waste my time on Kibana issues that are never going to get merged/fixed as Kibana code changes. Could there be some kind of purge effort for issues you guys never intend to fix and instead are waiting for a fix from some 3rd party vendor?

@JacobBrandt
Copy link
Contributor Author

So several ways to handle the content changes. Which way do you prefer? I'm fine with whatever you pick just let me know.

  • Add another commit to this pull request that removes the Leaflet issue code
  • Rebase and skip the commit for the Leaflet issue
  • Create a new pull request for the content changes

@thomasneirynck
Copy link
Contributor

@JacobBrandt you're right, this can be more clear. Those P-labels are often added before we know what the actual issue is, or what the fix would be. They are an indication of how important somebody thinks it is. And as this issue affects map-users in Kibana, it was added to that meta-ticket too, much like most other map issues.

I understand the confusion though. One thing to do, is ping on the issue that you're working on a fix. That will alert people for quicker feedback. That said, for this particular issue, it's really only by working through the problem that it became clear Leaflet does not have sufficient public API to accurately determine label bounds, so not sure if would have been revealed during an initial issue triage.


Since the discussion here is quite lengthy, I'd create a new PR with just the label change, thx

@thomasneirynck
Copy link
Contributor

Closing, will get new PR for label improvement

@JacobBrandt
Copy link
Contributor Author

@thomasneirynck Thanks for the explanation. That makes a lot of sense. I'll get the new PR done later tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants