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

feat: read color from drawGeojsonData properties if set #492

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Sep 2, 2024

Same functionality as geojsonData now !

If initial features are set to pre-populate the drawing layer, read the color property from drawGeojsonData if it's set, else default to the drawColor prop. Label text is already populated the same way.

Eg this map is produced by this sample data - I think this should enable us to highlight a specific feature based on the active tab in Map&Label
Screenshot from 2024-09-02 14-34-20

const map = document.querySelector("my-map");
map.drawGeojsonData = {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  -0.12779689203071595,
                  51.507483251157424
                ],
                [
                  -0.12782371412086485,
                  51.50738892768874
                ],
                [
                  -0.1276533938484192,
                  51.50742148182832
                ],
                [
                  -0.12770033250617982,
                  51.50751079691233
                ],
                [
                  -0.12779689203071595,
                  51.507483251157424
                ]
              ]
            ]
          },
          "properties": {
            "label": "1",
            "area.squareMetres": 96.62,
            "area.hectares": 0.009662
          }
        },
        {
          "type": "Feature",
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  -0.12757292757797242,
                  51.50743650680798
                ],
                [
                  -0.12767887483406065,
                  51.50734385268785
                ],
                [
                  -0.127508554561615,
                  51.50728625678846
                ],
                [
                  -0.1274106539325714,
                  51.50737891102574
                ],
                [
                  -0.12757292757797242,
                  51.50743650680798
                ]
              ]
            ]
          },
          "properties": {
            "color": "#A020F0",
            "area.squareMetres": 163.75,
            "area.hectares": 0.016375
          }
        },
        {
          "type": "Feature",
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
                  -0.12785992394256593,
                  51.50737139852703
                ],
                [
                  -0.12772179017829893,
                  51.50731046376956
                ],
                [
                  -0.1279095448093414,
                  51.507263719242815
                ],
                [
                  -0.12803694973754884,
                  51.50730044708928
                ],
                [
                  -0.12785992394256593,
                  51.50737139852703
                ]
              ]
            ]
          },
          "properties": {
            "label": "3",
            "area.squareMetres": 128.67,
            "area.hectares": 0.012866999999999998
          }
        }
      ]
    };

Copy link

netlify bot commented Sep 2, 2024

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit b398d80
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/66d5b352ae2553000845837b
😎 Deploy Preview https://deploy-preview-492--oslmap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jessicamcinchak jessicamcinchak requested a review from a team September 2, 2024 13:44
@jessicamcinchak jessicamcinchak merged commit cce3620 into main Sep 2, 2024
5 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/drawGeojsonData-feature-color branch September 2, 2024 16:39
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.

1 participant