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

Allow image option for PointComponent - Closes #209 #211

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

aloxe
Copy link
Contributor

@aloxe aloxe commented Jun 7, 2024

The current Point feature of the Geojson component can only be changed by changing the value of its radius.

 styleCallback={(feature) => {
          if (feature.geometry.type === "Point") {
            return {
              fill: "lightcoral",
              stroke: "darkred",
              strokeWidth: "2",
              r: "10",
            };
  }}
Screenshot 2024-06-07 at 9 35 50

The present change adds the possibility to add an svg path to the styleCallback that will be shown in place of the circle.

 styleCallback={(feature) => {
          if (feature.geometry.type === "Point") {
            return {
              fill: "lightcoral",
              stroke: "darkred",
              strokeWidth: "2",
              r: "10",
              path: "m 105.18118,144.78341 c 13.88218,-54.900853 47.12626,-20.15307 62.51039,-48.510217 11.48025,-21.161195 -7.88701,-40.52815 -23.30348,-40.545845 -12.98949,-0.01491 -23.75998,5.030014 -31.12524,15.691032 -9.61521,13.917797 -19.289599,24.284596 -8.08167,73.36503 m 32.30707,-76.511091 17.61856,12.899471 -17.30385,13.528373 z"
            };
  }}
Screenshot 2024-06-07 at 9 35 35

To be able to display correctly, the path must be passed as a string and all coordinates must be relative. ( it is possible to convert a path to relative here ).
Also note that the first point of the path will be the one placed on the feature Point coordinates. Make sure the first point of the path is the base point of your pin.
Of course, it is also possible to use a nicer svg path than the one in the example.

@aloxe
Copy link
Contributor Author

aloxe commented Jun 7, 2024

I could only test this change while implementing it in the file index.esm.js and with patching the pigeon-maps module. @mariusandra if there is another method to test I'd be happy to learn how.

Copy link
Owner

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Merged and out with 0.21.6

@mariusandra mariusandra merged commit f126796 into mariusandra:main Jun 12, 2024
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

Successfully merging this pull request may close these issues.

2 participants