Hi all,
I'm looking for a way to set the scale-unit to "Meters" for the Print-widget. Any help in the right direction appreaciated 🙂
Thanks,
Vincent
Hi Vincent,
I came across this issue as well. I wish the ESRI Dev team will add this as a property to the widget: "scaleBarOptions". My work around was to use interceptors in esriConfig and add the print service URL you are using for printing. here is the code snippet
const addInterceptor = () => { // call this function before initializing the Print widget
esriConfig.request.interceptors.push({
urls: printServiceUrl, // the URL of the print service and make sure it is the same url as the one used in the Print widget
before: (params: any) => {
if (params.requestOptions.query.Web_Map_as_JSON) {
const jsonRequest = JSON.parse(params.requestOptions.query.Web_Map_as_JSON);
jsonRequest.layoutOptions.scaleBarOptions = {
metricLabel: 'm',
metricUnit: 'esriMeters',
nonMetricLabel: 'ft',
nonMetricUnit: 'esriFeet',
};
params.requestOptions.query.Web_Map_as_JSON = JSON.stringify(jsonRequest);
}
},
});
};
Hi Richard, thanks for the solution 🙂 This is what I was looking for, it would indeed be good to have this property on the Print widget itself.
Have a good Christmas!