@@ -36,13 +36,13 @@ function _drawPolygon(ctx, vertices, indices, style, size, extent, invCtxScale,
36
36
}
37
37
38
38
// draw line or edge of polygon
39
- if ( style . stroke . color ) {
39
+ if ( style . stroke ) {
40
40
strokeStyle ( style , ctx , invCtxScale ) ;
41
41
ctx . stroke ( ) ;
42
42
}
43
43
44
44
// fill polygon only
45
- if ( canBeFilled && ( style . fill . color || style . fill . pattern ) ) {
45
+ if ( canBeFilled && style . fill ) {
46
46
fillStyle ( style , ctx , invCtxScale ) ;
47
47
ctx . fill ( ) ;
48
48
}
@@ -56,7 +56,7 @@ function fillStyle(style, ctx, invCtxScale) {
56
56
} else {
57
57
console . warn ( 'Raster pattern isn\'t completely supported on Ie and edge' ) ;
58
58
}
59
- } else if ( style . fill . color && ctx . fillStyle !== style . fill . color ) {
59
+ } else if ( ctx . fillStyle !== style . fill . color ) {
60
60
ctx . fillStyle = style . fill . color ;
61
61
}
62
62
if ( style . fill . opacity !== ctx . globalAlpha ) {
@@ -106,26 +106,31 @@ const coord = new Coordinates('EPSG:4326', 0, 0, 0);
106
106
function drawFeature ( ctx , feature , extent , style , invCtxScale ) {
107
107
const extentDim = extent . dimensions ( ) ;
108
108
const scaleRadius = extentDim . x / ctx . canvas . width ;
109
+ const globals = { zoom : extent . zoom } ;
109
110
110
111
for ( const geometry of feature . geometries ) {
111
112
if ( geometry . extent . intersectsExtent ( extent ) ) {
112
- const geoStyle = geometry . properties . style || style ;
113
- if ( feature . type === FEATURE_TYPES . POINT ) {
114
- // cross multiplication to know in the extent system the real size of
115
- // the point
116
- const px = ( Math . round ( geoStyle . point . radius * invCtxScale ) || 3 * invCtxScale ) * scaleRadius ;
117
- for ( const indice of geometry . indices ) {
118
- const offset = indice . offset * feature . size ;
119
- const count = offset + indice . count * feature . size ;
120
- for ( let j = offset ; j < count ; j += feature . size ) {
121
- coord . setFromArray ( feature . vertices , j ) ;
122
- if ( extent . isPointInside ( coord , px ) ) {
123
- drawPoint ( ctx , feature . vertices [ j ] , feature . vertices [ j + 1 ] , geoStyle , invCtxScale ) ;
113
+ const context = { globals, properties : ( ) => geometry . properties } ;
114
+ const contextStyle = ( geometry . properties . style || style ) . drawingStylefromContext ( context ) ;
115
+
116
+ if ( contextStyle ) {
117
+ if ( feature . type === FEATURE_TYPES . POINT ) {
118
+ // cross multiplication to know in the extent system the real size of
119
+ // the point
120
+ const px = ( Math . round ( contextStyle . point . radius * invCtxScale ) || 3 * invCtxScale ) * scaleRadius ;
121
+ for ( const indice of geometry . indices ) {
122
+ const offset = indice . offset * feature . size ;
123
+ const count = offset + indice . count * feature . size ;
124
+ for ( let j = offset ; j < count ; j += feature . size ) {
125
+ coord . setFromArray ( feature . vertices , j ) ;
126
+ if ( extent . isPointInside ( coord , px ) ) {
127
+ drawPoint ( ctx , feature . vertices [ j ] , feature . vertices [ j + 1 ] , contextStyle , invCtxScale ) ;
128
+ }
124
129
}
125
130
}
131
+ } else {
132
+ drawPolygon ( ctx , feature . vertices , geometry . indices , contextStyle , feature . size , extent , invCtxScale , ( feature . type == FEATURE_TYPES . POLYGON ) ) ;
126
133
}
127
- } else {
128
- drawPolygon ( ctx , feature . vertices , geometry . indices , geoStyle , feature . size , extent , invCtxScale , ( feature . type == FEATURE_TYPES . POLYGON ) ) ;
129
134
}
130
135
}
131
136
}
0 commit comments