Skip to content

feat: clip viewport based on geojson extent#363

Merged
DafyddLlyr merged 3 commits intomainfrom
jess/clip-map-viewport
Aug 14, 2023
Merged

feat: clip viewport based on geojson extent#363
DafyddLlyr merged 3 commits intomainfrom
jess/clip-map-viewport

Conversation

@jessicamcinchak
Copy link
Copy Markdown
Member

@jessicamcinchak jessicamcinchak commented Aug 13, 2023

Introduces an optional prop clipGeojsonData that can be set to disable a user panning/navigating outside of their own council.

I originally was trying to apply a clipping/mask layer but I think that requires more style tinkering than its worth in our case, and this simpler option of applying an extent to the viewport should satisfy what we need !

See these docs / examples to compare:

Next steps:

  • Review/merge this PR
  • Queue up new map release v0.7.5 #364
  • Open a planx-new branch with the upgrade
    • Set the clipGeojsonData based on the existing teams.setting.boundary geojson if it exists
    • Switch off static mode for document maps and generate a sample zip (planx-core)
    • Open pizza for user-testing (prompts to check addresses at border especially, does extent and current zoom still allow bordered addresse to appear "centered" etc? Are any valid addresses "unreachable" because of the extent?)

Ideally this can sit in user-testing while Jess is out this next week, then get finalised/merged next week. At which point we could also decide to revisit if our current storage of teams.settings.boundary is fine here or if we want to tweak that too in the background.

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 13, 2023

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit 9e33c69
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/64d9e126653cf10008974af8
😎 Deploy Preview https://deploy-preview-363--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.

Comment thread index.html
]
]
},
};
Copy link
Copy Markdown
Member Author

@jessicamcinchak jessicamcinchak Aug 13, 2023

Choose a reason for hiding this comment

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

lots of linter changes here, but this is the notable change to demo the clipped viewport !

is NOT translated to a proper Pitsby example yet, but can pick that up in a future PR.

[-10.76418, 49.528423, 1.9134116, 61.331151],
"EPSG:4326",
"EPSG:3857",
),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

again, lots of linter changes here, but this is the juicy bit !

geometry: {
coordinates: [],
},
};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Lit default prop values for optional props can feel a bit awkward, espcially for complex types like geojson object. Might be worth revisiting this in a future PR to touch all the geojson props at once 🔖

@jessicamcinchak
Copy link
Copy Markdown
Member Author

Netlify deploys are passing on retry fine but not updating Github CI here - not positive what's going on there yet https://app.netlify.com/sites/oslmap/deploys/64d897e517608f7a1ff157ac

@jessicamcinchak jessicamcinchak requested a review from a team August 13, 2023 08:47
@jessicamcinchak
Copy link
Copy Markdown
Member Author

@jessicamcinchak jessicamcinchak mentioned this pull request Aug 13, 2023
Copy link
Copy Markdown
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

Pulled the branch locally, installed dependencies and then updated lockfile and all worked as expected with CI.

PR is great - two small comments to discuss but I suspect straight GeoJSON is the right fit here.

Really appreciate the helpful comments and having the list of follow up tasks laid out so clearly - super helpful. I'll start picking them up so we can get this on a Pizza this sprint.

@property({ type: Boolean })
showPrint = false;

@property({ type: Object })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A simpler API might be to accept an extent e.g. [minx, miny, maxx, maxy]. We could then default to the UK extent here also.

It does put the onus on the consumer of this webcomponent to generate one however which may not suit BOPS as well as it suits us?

new GeoJSON().readFeature(this.clipGeojsonData, {
featureProjection: "EPSG:3857",
});
const clipExtent = clipFeature && clipFeature.getGeometry()?.getExtent();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suspect that we'll need to buffer this somewhat to get the functionality we want - the question is who's responsibility is it?

If a consumer adds a "clip" geojson but the map then shows more than they're clip that's quite odd / bad behaviour. We could add a buffer / scale value as an additional prop, or just leave as is and leave the responsibility to consumers.

I think I'd probably also go with not scaling / buffering here 👍 This might be something to specifically mention in docs / to BOPS though ("you probably want to buffer or scale the geometry to give a better user experience for those on the edges of areas").

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