-
Notifications
You must be signed in to change notification settings - Fork 0
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: Printing #263
feat: Printing #263
Conversation
✅ Deploy Preview for oslmap ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -39,11 +39,11 @@ | |||
} | |||
</style> --> | |||
</head> | |||
<body> | |||
<body style="font-family:Inter,Helvetica,sans-serif;"> |
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.
This was moved to test that font style is inherited in the PrintDialog
@@ -48,3 +54,115 @@ export function resetControl(listener: any, icon: string) { | |||
|
|||
return new Control({ element: element }); | |||
} | |||
|
|||
PrintDialog.prototype.scales = { |
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.
There's no way of setting this within the class - Viglino/ol-ext#766 (comment)
* This can not natively be done with this element, but it has all the inherited | ||
* functions from OL ScaleLine to allow us to set this | ||
*/ | ||
private syncScaleText() { |
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.
I spent a good while trying to make this a method on the CanvasScaleLine
class (or rather a child class) as really that's where it belongs and you can access the this.element
without query selectors etc.
The problem I hit was getting the correct map context from within than class, even when explicitly passing this.map
into the constructor.
@@ -35,6 +35,7 @@ function makeOSRasterBaseMap( | |||
source: new XYZ({ | |||
url: tileServiceURL, | |||
attributions: [copyright], | |||
crossOrigin: "anonymous", |
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.
This is a requirement for the canvas to access tiles - Viglino/ol-ext#673 (comment)
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.
I definitely don't understand how this works but the code you've added looks good.
I've added a couple of comments/questions but no show-stoppers.
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.
I'm sorry it's taken me so long to properly get to this one - I've looked at it many times and failed to hit "comment"!
Overall I'm happy with this solution and it functions perfectly for me, it's actually a lot less code than I expected it would be too. Solid work for a big-feeling feature 🖨️ 🎉
A couple general comments / questions (happy to chat about any of these outloud, please don't feel any pressure to type responses):
- You added "Pitsby docs" in the todo's, but I wonder if there's actually a case to intentionally omit an expample of the print button from docs because otherwise anyone could theoretically print OS basemaps via the "Sandbox" using our proxy endpoint to fetch vector tiles? Alastair commented about this legal difference in web maps versus print a bit ago if you recall? Obviously someone could still find their own way to this, but at least we wouldn't be advertising it?
- I'm curious about reasons you chose
ol-ext
, rather than say using thehtml2canvas
&jsPDF
approach in the openlayers examples https://openlayers.org/en/latest/examples/print-to-scale.html (obvious downside being would need to roll our own dialog inputs I guess)? With the funny scale issue going on, I'm curious about effort involved to sense check against a different library and see if clears it up - or if it's just a quirk of printing we're going to live with (I'm also totally OK with this if councils are and will be curious to see if it gets noticed in UAT)
@jessicamcinchak To summarise our conversation on this -
|
Apologies that this one has taken so long to see any daylight 🌤️ I kept coming back and tweaking... it's pretty hacky in places.
I'm using
ol-ext/printDialog
(docs) to allow the map to be printed to PDF/PNG/JPG at set scales.The documentation is pretty poor for
ol-ext
so there's been a lot of figuring out and reverse engineering.This meets the requirements of the following ticket (and then some) - https://trello.com/c/jVS79IdF/2230-can-automatically-generated-location-plan-click-to-standard-scales
To do...