Skip to content

Commit

Permalink
Fix #88 update default print style
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Jul 11, 2018
1 parent f597d96 commit 163722b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 47 deletions.
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

0 comments on commit 163722b

Please sign in to comment.