Skip to content

Commit

Permalink
fix linestring layer style #2
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeLafreniere18 committed Dec 9, 2019
1 parent 462afd7 commit d598a65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions packages/geo/src/lib/overlay/shared/overlay.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ function createOverlayLayerStyle(): (olFeature: OlFeature) => olstyle.Style {
* Create a basic style for lines and polygons
* @returns Style
*/
export function createOverlayDefaultStyle(color: number[] = [0, 161, 222, 0.3], text?: string, opacity?: number): olstyle.Style {
export function createOverlayDefaultStyle(
{text, fillOpacity, strokeOpacity, color = [0, 161, 222, 0.3]}:
{text?: string, fillOpacity?: number, strokeOpacity?: number, color?: number[]} = {}
): olstyle.Style {
const fillWithOpacity = color.slice(0);
const strokeWithOpacity = color.slice(0);
strokeWithOpacity[3] = 1;
if (opacity) {
fillWithOpacity[3] = opacity;
strokeWithOpacity[3] = 0.5;
if (fillOpacity) {
fillWithOpacity[3] = fillOpacity;
}
if (strokeOpacity) {
strokeWithOpacity[3] = strokeOpacity;
}

const stroke = new olstyle.Stroke({
Expand Down Expand Up @@ -91,7 +96,10 @@ export function createOverlayDefaultStyle(color: number[] = [0, 161, 222, 0.3],
* Create a marker style for points
* @returns Style
*/
export function createOverlayMarkerStyle(color: string = 'blue', text?: string, opacity: number = 1): olstyle.Style {
export function createOverlayMarkerStyle(
{text, opacity = 1, color = 'blue'}:
{text?: string, opacity?: number, color?: string} = {}
): olstyle.Style {
let iconColor;
switch (color) {
case 'blue':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ export class RoutingFormComponent implements OnInit, AfterViewInit, OnDestroy {
return;
}
if (geometry.getType() === 'Point') {
const olStyle = createOverlayMarkerStyle(stopColor, stopText);
const olStyle = createOverlayMarkerStyle({color: stopColor, text: stopText});
feature.setStyle(olStyle);
}
this.routingStopsOverlayDataSource.ol.addFeature(feature);
Expand Down

0 comments on commit d598a65

Please sign in to comment.