@@ -11,7 +11,7 @@ const LocaleUtils = require('./LocaleUtils');
1111const { extraMarkers} = require ( './MarkerUtils' ) ;
1212const { geometryFunctions, fetchStyle, hashAndStringify} = require ( './VectorStyleUtils' ) ;
1313const { set} = require ( './ImmutableUtils' ) ;
14- const { values, isNil, slice, head, castArray, last, isArray, findIndex} = require ( 'lodash' ) ;
14+ const { values, isNil, slice, head, castArray, last, isArray, findIndex, isString } = require ( 'lodash' ) ;
1515const uuid = require ( 'uuid' ) ;
1616const turfCenter = require ( '@turf/center' ) . default ;
1717const assign = require ( 'object-assign' ) ;
@@ -96,9 +96,14 @@ const getStylesObject = ({type = "Point", features = []} = {}) => {
9696} ;
9797const getProperties = ( props = { } , messages = { } ) => ( { title : LocaleUtils . getMessageById ( messages , "annotations.defaulttitle" ) !== "annotations.defaulttitle" ? LocaleUtils . getMessageById ( messages , "annotations.defaulttitle" ) : "Default title" , id : uuidv1 ( ) , ...props } ) ;
9898
99+ const getDashArrayFromStyle = dashArray => {
100+ return isString ( dashArray ) && dashArray || isArray ( dashArray ) && dashArray . join ( " " ) ;
101+ } ;
102+
99103const annStyleToOlStyle = ( type , tempStyle , label = "" ) => {
100104 let style = tempStyle && tempStyle [ type ] ? tempStyle [ type ] : tempStyle ;
101105 const s = style ;
106+ const dashArray = s . dashArray ? getDashArrayFromStyle ( s . dashArray ) : "" ;
102107 switch ( type ) {
103108 case "MultiPolygon" :
104109 case "Polygon" :
@@ -108,14 +113,16 @@ const annStyleToOlStyle = (type, tempStyle, label = "") => {
108113 "strokeOpacity" : s . opacity ,
109114 "strokeWidth" : s . weight ,
110115 "fillColor" : rgbaTorgb ( s . fillColor ) ,
111- "fillOpacity" : s . fillOpacity
116+ "fillOpacity" : s . fillOpacity ,
117+ "strokeDashStyle" : dashArray
112118 } ;
113119 case "LineString" :
114120 case "MultiLineString" :
115121 return {
116122 "strokeColor" : rgbaTorgb ( s . color ) ,
117123 "strokeOpacity" : s . opacity ,
118- "strokeWidth" : s . weight
124+ "strokeWidth" : s . weight ,
125+ "strokeDashStyle" : dashArray
119126 } ;
120127 case "Text" :
121128 return {
@@ -133,7 +140,8 @@ const annStyleToOlStyle = (type, tempStyle, label = "") => {
133140 "stroke" : true ,
134141 "strokeColor" : rgbaTorgb ( s . color ) ,
135142 "strokeOpacity" : s . opacity ,
136- "strokeWidth" : s . weight
143+ "strokeWidth" : s . weight ,
144+ "strokeDashStyle" : dashArray
137145 } ;
138146 case "Point" :
139147 case "MultiPoint" : {
@@ -177,6 +185,7 @@ const annStyleToOlStyle = (type, tempStyle, label = "") => {
177185 "strokeColor" : "#FF0000" ,
178186 "pointRadius" : 5 ,
179187 "strokeOpacity" : 1 ,
188+ "strokeDashStyle" : dashArray ,
180189 "strokeWidth" : 1
181190 } ;
182191 }
@@ -565,7 +574,8 @@ const AnnotationsUtils = {
565574 isCompletePolygon : ( coords = [ [ [ ] ] ] ) => {
566575 const validCoords = coords [ 0 ] . filter ( AnnotationsUtils . validateCoordsArray ) ;
567576 return validCoords . length > 3 && head ( validCoords ) [ 0 ] === last ( validCoords ) [ 0 ] && head ( validCoords ) [ 1 ] === last ( validCoords ) [ 1 ] ;
568- }
577+ } ,
578+ getDashArrayFromStyle
569579} ;
570580
571581module . exports = AnnotationsUtils ;
0 commit comments