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

Update default print style #3065

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/client/components/map/openlayers/VectorStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const defaultStyles = {
"MultiPolygon": STYLE_POLYGON
};

const strokeStyle = (options, defaultsStyle = {color: 'blue', width: 3, lineDash: [4]}) => ({
const strokeStyle = (options, defaultsStyle = {color: 'blue', width: 3, lineDash: [6]}) => ({
stroke: new ol.style.Stroke(
options.style ?
options.style.stroke || {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('Test VectorStyle', () => {
expect(olFill.getColor()).toBe('rgba(0, 0, 255, 0.1)');
expect(olStroke.getColor()).toBe('blue');
expect(olStroke.getWidth()).toBe(3);
expect(olStroke.getLineDash()).toEqual([4]);
expect(olStroke.getLineDash()).toEqual([6]);

const options = {
style: {
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('Test VectorStyle', () => {
expect(olFill.getColor()).toBe('rgba(0, 0, 255, 0.1)');
expect(olStroke.getColor()).toBe('blue');
expect(olStroke.getWidth()).toBe(3);
expect(olStroke.getLineDash()).toEqual([4]);
expect(olStroke.getLineDash()).toEqual([6]);

const options = {
style: {
Expand Down
90 changes: 46 additions & 44 deletions web/client/utils/PrintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,50 +378,52 @@ const PrintUtils = {
*/
getOlDefaultStyle(layer) {
switch (getGeomType(layer)) {
case 'Polygon':
case 'MultiPolygon': {
return {
"fillColor": "#0000FF",
"fillOpacity": 0.1,
"strokeColor": "#0000FF",
"strokeOpacity": 1,
"strokeWidth": 3
};
}
case 'MultiLineString':
case 'LineString':
return {
"strokeColor": "#0000FF",
"strokeOpacity": 1,
"strokeWidth": 3
};
case 'Point':
case 'MultiPoint': {
return layer.styleName === "marker" ? {
"externalGraphic": "http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/images/marker-icon.png",
"graphicWidth": 25,
"graphicHeight": 41,
"graphicXOffset": -12, // different offset
"graphicYOffset": -41
} : {
"fillColor": "#FF0000",
"fillOpacity": 0,
"strokeColor": "#FF0000",
"pointRadius": 5,
"strokeOpacity": 1,
"strokeWidth": 1
};
}
default: {
return {
"fillColor": "#0000FF",
"fillOpacity": 0.1,
"strokeColor": "#0000FF",
"pointRadius": 5,
"strokeOpacity": 1,
"strokeWidth": 1
};
}
case 'Polygon':
case 'MultiPolygon': {
return {
"fillColor": "#0000FF",
"fillOpacity": 0.1,
"strokeColor": "#0000FF",
"strokeOpacity": 1,
"strokeWidth": 3,
"strokeDashstyle": "dash",
"strokeLinecap": "round"
};
}
case 'MultiLineString':
case 'LineString':
return {
"strokeColor": "#0000FF",
"strokeOpacity": 1,
"strokeWidth": 3
};
case 'Point':
case 'MultiPoint': {
return layer.styleName === "marker" ? {
"externalGraphic": "http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/images/marker-icon.png",
"graphicWidth": 25,
"graphicHeight": 41,
"graphicXOffset": -12, // different offset
"graphicYOffset": -41
} : {
"fillColor": "#FF0000",
"fillOpacity": 0,
"strokeColor": "#FF0000",
"pointRadius": 5,
"strokeOpacity": 1,
"strokeWidth": 1
};
}
default: {
return {
"fillColor": "#0000FF",
"fillOpacity": 0.1,
"strokeColor": "#0000FF",
"pointRadius": 5,
"strokeOpacity": 1,
"strokeWidth": 1
};
}
}
}
};
Expand Down
6 changes: 6 additions & 0 deletions web/client/utils/__tests__/PrintUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ describe('PrintUtils', () => {
const style = PrintUtils.getOlDefaultStyle({features: [{geometry: {type: "Polygon"}}]});
expect(style).toExist();
expect(style.strokeWidth).toBe(3);
expect(style.strokeDashstyle).toBe("dash");
expect(style.strokeLinecap).toBe("round");
expect(style.strokeColor).toBe("#0000FF");
expect(style.fillColor).toBe("#0000FF");
expect(style.fillOpacity).toBe(0.1);
expect(style.strokeOpacity).toBe(1);

});
it('vector layer default line style', () => {
Expand Down