Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

derive width and height from feature property #14

Open
andrewharvey opened this issue Apr 29, 2018 · 3 comments
Open

derive width and height from feature property #14

andrewharvey opened this issue Apr 29, 2018 · 3 comments
Labels
iOS SDK parity Needed for feature parity with the Mapbox Maps SDK for iOS

Comments

@andrewharvey
Copy link
Collaborator

The accessible elements currently have a fixed width and height given in the plugin options. It would be nice to set from an expression evaluated per feature.

For example if you had a circle layer with variable circle-radius you could ensure the accessible element had the same width/height as the circle, so the focus style would match what's on the screen.

@1ec5 1ec5 added the iOS SDK parity Needed for feature parity with the Mapbox Maps SDK for iOS label Apr 29, 2018
@orangemug
Copy link

It looks like this has been fixed already

const featureBbox = bbox(feature);
const bl = this.map.project([featureBbox[0], featureBbox[1]]);
const tr = this.map.project([featureBbox[2], featureBbox[3]]);
width = Math.abs(tr.x - bl.x);
height = Math.abs(tr.y - bl.y);
position = {
x: ((tr.x + bl.x) / 2),
y: ((tr.y + bl.y) / 2),
};
}
feature.marker.style.width = `${width}px`;
feature.marker.style.height = `${height}px`;

@andrewharvey
Copy link
Collaborator Author

It looks like this has been fixed already

That's for the source geometry only, it doesn't take into account the paint/layout properties on the layer which create a rendered feature which has a different box to the source geometry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS SDK parity Needed for feature parity with the Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

4 participants
@andrewharvey @orangemug @1ec5 and others