-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add rect example #15841
Add rect example #15841
Conversation
An even simpler way to produce a rectangle geometry from a BBOX is the the
|
📦 Preview the website for this branch here: https://deploy-preview-15841--ol-site.netlify.app/. |
It might make sense to use geographic coordinates here. For the view's center, you could use |
@mike-000 That's true, I didn't know about that function yet. Still, I kind of like that the way I did it illustrates how a Polygon works technically. @ahocevar In this case I had the coordinates in EPSG:3857 anyway, so for me this was perfect, but you're right, the average user is more likely to be dealing with EPSG:4326. -> How about I expand the example to contain four rectangles? One the way it is right now, one with |
@christophfriedrich I'd really keep it as simple as possible. Really boil it down to the simplest possible code. As you noticed already, we have plenty of examples with quite some complexity, but lack simple ones. |
Okay, you've got a point there. Taking simplicity as the maxim, I changed the example to use Mike's suggestion.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @christophfriedrich
Earlier today I wanted to put a simple rectangle on a map to visualise a bbox, but only found examples that used super advanced functionality like custom polygon styles etc. There seemed to be none that explains this quite common usecase on a very basic level ("you need a Feature that has a Geometry which is in this case a Polygon which expects an array of linear rings which look like this"). So after finishing my tiny application, I thought I could generalise it a little and contribute it here.
Feel free to rename it/edit the description etc.
Possibly it would be nice to add a second Polygon that actually has multiple linear rings to illustrate "how to cut holes into a shape".