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

how to rotate a Icon? #27

Open
easy868 opened this issue Jun 19, 2024 · 5 comments
Open

how to rotate a Icon? #27

easy868 opened this issue Jun 19, 2024 · 5 comments
Labels

Comments

@easy868
Copy link

easy868 commented Jun 19, 2024

const point = new Feature({
name: 'point',
geometry: new Point([2384267.0573564973, 7557371.884852641])
})
point.setStyle([
new Style({
image: new Icon({
size: [112, 30], // 尺寸
src: zhuchi // 图片url
// scale: 0.1 // 缩放比例
})
})
])

@ghettovoice
Copy link
Owner

Hello @easy868 ,
ol-rotate-feature executes a geometric rotation by changing the geometry of the feature.
In your case you need to listen for rotate* events and change point image style manually.
There is a demo https://jsfiddle.net/ghettovoice/cs39h7k2/75/.
If you need select interaction too, then you should provide custom styles for it, so you can rotate point icon during selection.

@easy868
Copy link
Author

easy868 commented Jun 20, 2024

Hello @easy868 , ol-rotate-feature executes a geometric rotation by changing the geometry of the feature. In your case you need to listen for rotate* events and change point image style manually. There is a demo https://jsfiddle.net/ghettovoice/cs39h7k2/75/. If you need select interaction too, then you should provide custom styles for it, so you can rotate point icon during selection.

@ghettovoice Thank you for the demo

@easy868
Copy link
Author

easy868 commented Jun 25, 2024

Hello @easy868 , ol-rotate-feature executes a geometric rotation by changing the geometry of the feature. In your case you need to listen for rotate* events and change point image style manually. There is a demo https://jsfiddle.net/ghettovoice/cs39h7k2/75/. If you need select interaction too, then you should provide custom styles for it, so you can rotate point icon during selection.

hello @ghettovoice, When I rotate it multiple times, the page becomes sluggish and there is a memory overflow,could you help me?

@ghettovoice
Copy link
Owner

Hmm, I found that with a smaller icon (no need to scale it by the scale option of the style) there is no performance penalty.
https://jsfiddle.net/ghettovoice/cs39h7k2/80/

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants