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

Polygon with Holes Marker #1293

Closed
AliHasan71 opened this issue Apr 18, 2024 · 12 comments
Closed

Polygon with Holes Marker #1293

AliHasan71 opened this issue Apr 18, 2024 · 12 comments
Labels
Milestone

Comments

@AliHasan71
Copy link

Describe your problem

I am able to successfully create polygon markers. Is there any way to define polygons with holes using this library?

Online demo URL

No response

Photo Sphere Viewer version

5.4.2

Plugins loaded

No response

Additional context

No response

@AliHasan71
Copy link
Author

Is there any workaround solution in the meantime? Like using paths to define polygons instead or patterns along with polygons?

When spherical coordinates are given for the polygon attribute, how are they transformed into an SVG points?

@mistic100
Copy link
Owner

Please give a try to this branch https://github.com/mistic100/Photo-Sphere-Viewer/tree/polygon-hole

The definition of a polygon with holes is similar to GeoJSON syntax if you are familiar with it.

                                polygonPixels: [
                                    [
                                        // main shape
                                        [2941, 1413], [3042, 1402], [3041, 1555], [2854, 1559],
                                        [2739, 1516], [2775, 1469], [2941, 1413],
                                    ],
                                    [
                                        // first hole
                                        [2900, 1450], [2950, 1450], [2950, 1500], [2900, 1500],
                                    ]
                                ],

@AliHasan71
Copy link
Author

Yes I am familiar with it. I actually tried that and it didn't work previously. But I see you have now made a Polygon into a Path.

I am using Photo Sphere Viewer via npm. Is there any way I can test this branch from there? How can I test it with my project?

@mistic100
Copy link
Owner

you will have to build it locally and use "npm link"/"yarn link"

https://photo-sphere-viewer.js.org/guide/development.html

@AliHasan71
Copy link
Author

Works nicely! Just had to add the fillRule property to the svgStyle so that filled polygons also have the holes cutout.

Any chance this can be incorporated in the next release? Thanks a bunch.

@mistic100
Copy link
Owner

mistic100 commented May 16, 2024

can you provide an example of your polygon where you have to change fillRule ? because I don't need it on the demo, and it should not be necessary if the polygon is not selfcrossing

@mistic100 mistic100 added this to the 5.8.0 milestone May 16, 2024
@AliHasan71
Copy link
Author

So firstly, after testing the branch locally, plugin-markers.html in the examples folder doesn't seem to open on the browser.

My polygon is not selfcrossing. Please refer to the below images.

Without fillRule in SVGStyle:

Screenshot 2024-05-16 at 5 00 26 PM Screenshot 2024-05-16 at 5 01 21 PM

With fillRule in SVGStyle

Screenshot 2024-05-16 at 5 02 27 PM Screenshot 2024-05-16 at 5 02 42 PM

@mistic100
Copy link
Owner

I need the actual data !

@AliHasan71
Copy link
Author

Sorry about that. I have attached the entire MarkerConfig JSON, which includes the polygon vertices.
polygon.json

@mistic100
Copy link
Owner

Ok I understand the problem : I forced the holes coordinates to be in reverse order, but as you already did it (rightfully), it cancels out

innerPoints += (i === 0 ? innerPos : innerPos.reverse())

I will remove this array inversion.

@AliHasan71
Copy link
Author

Yes that makes complete sense why the evenodd value for the fillStyle property made it work regardless.

I have tested it and everything works perfectly including hovering, tooltip, etc. Thank you for the feature! Looking forward to the 5.8.0 release.

Copy link

This feature/bug fix has been released in version 5.7.4.

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