@@ -64,42 +64,38 @@ const FeatureToolTip = (function _() {
64
64
}
65
65
}
66
66
67
- function getGeometryProperties ( geometry ) {
68
- return function properties ( ) { return geometry . properties ; } ;
69
- }
70
-
71
67
function fillToolTip ( features , layer , options ) {
72
68
let content = '' ;
73
69
let feature ;
74
70
let geometry ;
75
- let style ;
71
+ const style = layer . style ;
76
72
let fill ;
77
73
let stroke ;
78
74
let symb = '' ;
79
75
let prop ;
80
76
77
+ const context = style . context ;
78
+
81
79
for ( let p = 0 ; p < features . length ; p ++ ) {
82
80
feature = features [ p ] ;
83
81
geometry = feature . geometry ;
84
- style = ( geometry . properties && geometry . properties . style ) || feature . style || layer . style ;
85
- const context = { globals : { } , properties : getGeometryProperties ( geometry ) } ;
86
- style = style . applyContext ( context ) ;
82
+
83
+ context . setFeature ( feature ) ;
84
+ context . setGeometry ( geometry ) ;
87
85
88
86
if ( feature . type === itowns . FEATURE_TYPES . POLYGON ) {
89
87
symb = '◼' ;
90
- if ( style ) {
91
- fill = style . fill && style . fill . color ;
92
- stroke = style . stroke && ( '1.25px ' + style . stroke . color ) ;
93
- }
88
+ fill = style . fill && style . fill . color ;
89
+ stroke = style . stroke && ( '1.25px ' + style . stroke . color ) ;
94
90
} else if ( feature . type === itowns . FEATURE_TYPES . LINE ) {
95
91
symb = '━' ;
96
- fill = style && style . stroke && style . stroke . color ;
92
+ fill = style . stroke && style . stroke . color ;
97
93
stroke = '0px' ;
98
94
} else if ( feature . type === itowns . FEATURE_TYPES . POINT ) {
99
95
symb = '●' ;
100
- if ( style && style . point ) { // Style and style.point can be undefined if no style options were passed
101
- fill = style . point . color ;
102
- stroke = '1.25px ' + style . point . line ;
96
+ if ( style . point || style . icon ) { // Style and style.point can be undefined if no style options were passed
97
+ fill = ( style . point && style . point . color ) || ( style . icon && style . icon . color ) ;
98
+ stroke = '1.25px ' + ( ( style . point && style . point . line ) || 'black' ) ;
103
99
}
104
100
}
105
101
@@ -109,10 +105,10 @@ const FeatureToolTip = (function _() {
109
105
content += '</span>' ;
110
106
111
107
if ( geometry . properties ) {
112
- content += ( geometry . properties . description || geometry . properties . name || geometry . properties . nom || layer . name || '' ) ;
108
+ content += ( geometry . properties . description || geometry . properties . name || geometry . properties . nom || geometry . properties . title || layer . name || '' ) ;
113
109
}
114
110
115
- if ( feature . type === itowns . FEATURE_TYPES . POINT ) {
111
+ if ( feature . type === itowns . FEATURE_TYPES . POINT && options . writeLatLong ) {
116
112
content += '<br/><span class="coord">long ' + feature . coordinates [ 0 ] . toFixed ( 4 ) + '</span>' ;
117
113
content += '<br/><span class="coord">lat ' + feature . coordinates [ 1 ] . toFixed ( 4 ) + '</span>' ;
118
114
}
@@ -231,8 +227,8 @@ const FeatureToolTip = (function _() {
231
227
}
232
228
233
229
const opts = options || { filterAllProperties : true } ;
234
- opts . filterProperties = opts . filterProperties == undefined ? [ ] : opts . filterProperties ;
235
- opts . filterProperties . concat ( [ 'name' , 'nom' , 'style' , 'description' ] ) ;
230
+ opts . filterProperties = opts . filterProperties === undefined ? [ ] : opts . filterProperties ;
231
+ opts . writeLatLong = opts . writeLatLong || false ;
236
232
237
233
layers . push ( { layer : layer , options : opts } ) ;
238
234
layersId . push ( layer . id ) ;
0 commit comments