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

Clickable point features, fires featureclick event #71

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

Conversation

nickw1
Copy link
Collaborator

@nickw1 nickw1 commented Apr 29, 2020

Clickable Kothic layer; recreating PR #66 from three years ago which I have closed.
Decided to do a clean fork and create a single commit as the previous one had become messy.


var lowest = Number.MAX_VALUE, nearestFeature = null;
for(var i = 0; i < this._data[key].features.length; i++) {
var dx = Math.abs(this._data[key].features[i].coordinates[0] - dataX), dy = Math.abs(this._data[key].features[i].coordinates[1] - dataY);
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this one will not work on polygons? I don't see a safeguard on that.

this._data[key].features = [];
for(var i = 0; i < data.features.length; i++) {
if(data.features[i].type == "Point") {
this._data[key].features.push(data.features[i]);
Copy link
Member

Choose a reason for hiding this comment

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

Oh, sorry, now I see the safeguard.

Will it make sense to also append the reprpoint of polygons to make them clickable too? Shouldn't be a huge investment but will help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Komzpa yes good point, shouldn't be too difficult. Thanks.

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

Successfully merging this pull request may close these issues.

2 participants