-
Notifications
You must be signed in to change notification settings - Fork 4
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 vectorlayer styling in map-cesium #207
Changes from 3 commits
f20b987
0cafdfa
f3649e6
e5948e5
94fa819
da10905
ce9366d
73aab95
49ec3de
404323b
3f6f355
0db77c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -620,28 +620,40 @@ export class MapCesiumService { | |
|
||
private create_geojson_layer(l: VectorLayer): GeoJsonDataSource { | ||
const newGeoJsonDataSource = new GeoJsonDataSource(); | ||
// default GeoJsonDataSource values | ||
let fillColor = GeoJsonDataSource.fill; | ||
let strokeColor = GeoJsonDataSource.stroke; | ||
let strokeWidth = GeoJsonDataSource.strokeWidth; | ||
// default UKIS values | ||
let fillColor = Color.fromCssColorString('#FFFFFF99'); | ||
let strokeColor = Color.fromCssColorString('#3399CC'); | ||
let strokeWidth = 1; | ||
let strokeOpacity = 1; | ||
let fillOpacity = 1; | ||
let clamp = false; | ||
if(l.options){ | ||
if(l.options['fillColor']){ | ||
fillColor = Object.freeze(Color.fromCssColorString(l.options['fillColor'])); | ||
} | ||
if(l.options['strokeColor']){ | ||
strokeColor = Object.freeze(Color.fromCssColorString(l.options['strokeColor'])); | ||
} | ||
if(l.options['strokeWidth']){ | ||
strokeWidth = l.options['strokeWidth']; | ||
|
||
if(l.options && l.options.style){ | ||
const styleProperties = l.options.style(l.data)[0]; | ||
if(styleProperties){ | ||
fillColor = Color.fromCssColorString(styleProperties.fill_.color_) || fillColor; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not optimal to use private properties from OpenLayers here, but we can change that later. Maybe we can define some common style properties. l.options.style{
fillColor?: string;
strokeColor?: string;
strokeWidth?: string;
strokeOpacity?: number;
fillOpacity?: number;
circleRadius?: number;
iconImg?: any;
...
} @voinSR what do you think about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be ideal. |
||
strokeColor = Color.fromCssColorString(styleProperties.stroke_.color_) || strokeColor; | ||
strokeWidth = styleProperties.stroke_.width_ || strokeWidth; | ||
} | ||
if(l.options['clampToGround']){ | ||
clamp = l.options['clampToGround']; | ||
} | ||
} | ||
} | ||
// as Cesium cannot handle an opacity for the whole datasource, we need to modify the color opacity, | ||
// in case the cesium color already has an opacity value | ||
if(fillColor.alpha != l.opacity){ | ||
fillOpacity = l.opacity*fillColor.alpha; | ||
}else{ | ||
fillOpacity = l.opacity; | ||
} | ||
if(strokeColor.alpha != l.opacity){ | ||
strokeOpacity = l.opacity*strokeColor.alpha; | ||
}else{ | ||
strokeOpacity = l.opacity; | ||
} | ||
const dataSourceOptions = { | ||
fill: fillColor.withAlpha(l.opacity/1.5), | ||
stroke: strokeColor.withAlpha(l.opacity), | ||
fill: fillColor.withAlpha(fillOpacity), | ||
stroke: strokeColor.withAlpha(strokeOpacity), | ||
strokeWidth: strokeWidth, | ||
clampToGround: clamp | ||
} as GeoJsonDataSource.LoadOptions; | ||
|
@@ -652,7 +664,7 @@ export class MapCesiumService { | |
|
||
newGeoJsonDataSource.load(l.data, dataSourceOptions); | ||
newGeoJsonDataSource.show = l.visible; | ||
newGeoJsonDataSource.name = l.id; | ||
newGeoJsonDataSource.name = l.name; | ||
|
||
this.dataSourceOpacity.set(l.id, l.opacity); | ||
return newGeoJsonDataSource; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can find a better solution here so that the values are not duplicated in the object.
Here is how this object is used in the other mapping libraries
map-ol:
ukis-frontend-libraries/projects/map-ol/src/lib/map-ol.service.ts
Line 1140 in dd51dd6
ukis-frontend-libraries/projects/map-ol/src/lib/map-ol.service.ts
Line 1184 in dd51dd6
ukis-frontend-libraries/projects/map-ol/src/lib/map-ol.service.ts
Line 933 in dd51dd6
map-maplibre:
ukis-frontend-libraries/projects/map-maplibre/src/lib/maplibre-layers.helpers.ts
Line 188 in dd51dd6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a way to access the style properties in a similar way as in map-maplibre. Therefore, I removed the duplicate entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice.