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

如何实现倾斜椭圆 #714

Closed
JoyTroy opened this issue Jul 7, 2018 · 3 comments
Closed

如何实现倾斜椭圆 #714

JoyTroy opened this issue Jul 7, 2018 · 3 comments

Comments

@JoyTroy
Copy link

JoyTroy commented Jul 7, 2018

maptalks's version and what browser you use?
----v0.40.2 Google

Issue description

maptalks能否实现倾斜的椭圆?
Polygon可以根据rotate方法实现多边形按角度倾斜,原理是对多边形上的几个坐标节点按角度重新计算各自的经纬度坐标;
而扩展了Polygon的Ellipse(椭圆)等这类图形似乎没法按照同样的方式作到倾斜,因为绘制椭圆只需要传递椭圆中心和宽高等参数,没法获取到圆边界的所有节点坐标。
主要官方API没找到例子啊 : (
有啥建议不?

Please provide a reproduction URL (on any jsfiddle like site)

@fuzhenn
Copy link
Member

fuzhenn commented Jul 7, 2018

可以试试:

const ellipse = new maptalks.Ellipse(...);

const polygon = new maptalks.Polygon(ellipse.getShell());

polygon.rotate(60);

我写了一个jsfiddle:
http://jsfiddle.net/ba3g84rw/2/

问一下一般是什么场合需要用到旋转的椭圆?如果需要的人多,我会考虑给ellipse直接支持旋转

@JoyTroy
Copy link
Author

JoyTroy commented Jul 7, 2018

哇,非常感谢,看邮件你那儿还是半夜呐,抱歉打扰啊;
此处的倾斜椭圆是用于配合虚线标识一个相对规则的范围,场景比较简单。就是调用API的过程中发现
Ellipse类的 rotate(angle, pivot)方法无法生效,看了源码才知道,虽然扩展了Polygon,但实际上Ellipse类继承的 rotate方法有点徒有其表,直接调用的话只会操作椭圆的圆心,容易把人误导。

@fuzhenn
Copy link
Member

fuzhenn commented Jul 8, 2018

不客气。

我想暂时先在示例中增加示例,未来看大家反馈,再决定是否直接为ellipse直接增加旋转支持

maptalks/examples#77

先关闭此issue

@fuzhenn fuzhenn closed this as completed Jul 8, 2018
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

No branches or pull requests

2 participants