11var markerIcon = require ( './img/marker-icon.png' ) ;
22var markerShadow = require ( './img/marker-shadow.png' ) ;
3- var extraMarker = require ( './img/markers_default.png' ) ;
4- var extraMarkerShadow = require ( './img/markers_shadow.png' ) ;
53var ol = require ( 'openlayers' ) ;
64
75const assign = require ( 'object-assign' ) ;
86
9- const csstree = require ( 'css-tree' ) ;
10- const css = require ( 'raw-loader!./font-awesome.txt' ) ;
7+ const MarkerUtils = require ( '../../../utils/MarkerUtils' ) ;
8+ const markers = MarkerUtils . extraMarkers ;
9+ const extraMarker = markers . icons [ 0 ] ;
10+ const extraMarkerShadow = markers . icons [ 1 ] ;
1111
12- const getNodeOfType = ( node , condition ) => {
13- if ( condition ( node ) ) {
14- return node ;
15- }
16- if ( node . children ) {
17- return node . children . reduce ( ( previous , current ) => {
18- const result = getNodeOfType ( current , condition ) ;
19- return result || previous ;
20- } , null ) ;
21- }
22- return null ;
23- } ;
24-
25- const parsedCss = csstree . toPlainObject ( csstree . parse ( css ) ) ;
26-
27- const glyphs = parsedCss . children . reduce ( ( previous , rule ) => {
28- if ( rule . prelude ) {
29- const classSelector = getNodeOfType ( rule . prelude , ( node ) => node . type === 'ClassSelector' ) ;
30- const pseudoClassSelector = getNodeOfType ( rule . prelude , ( node ) => node . type === 'PseudoClassSelector' ) ;
31- if ( classSelector && classSelector . name && classSelector . name . indexOf ( 'fa-' ) === 0 && pseudoClassSelector && pseudoClassSelector . name === 'before' ) {
32- const text = getNodeOfType ( getNodeOfType ( rule . block , ( node ) => node . type === 'Declaration' && node . property === 'content' ) . value , ( node ) => node . type === 'String' ) . value ;
33- /* eslint-disable */
34- return assign ( previous , {
35- [ classSelector . name . substring ( 3 ) ] : eval ( "'\\u" + text . substring ( 2 , text . length - 1 ) + "'" )
36- } ) ;
37- /* eslint-enable */
38- }
39- }
40- return previous ;
41- } , { } ) ;
42-
43-
44- const markers = {
45- size : [ 36 , 46 ] ,
46- colors : [ 'red' , 'orange-dark' , 'orange' , 'yellow' , 'blue-dark' , 'blue' , 'cyan' , 'purple' , 'violet' , 'pink' , 'green-dark' , 'green' ,
47- 'green-light' , 'black' , 'white' ] ,
48- shapes : [ 'circle' , 'square' , 'star' , 'penta' ]
49- } ;
12+ const glyphs = MarkerUtils . getGlyphs ( 'fontawesome' ) ;
5013
5114const image = new ol . style . Circle ( {
5215 radius : 5 ,
@@ -170,7 +133,7 @@ function getMarkerStyle(options) {
170133 } else {
171134 markerStyle = [ new ol . style . Style ( {
172135 image : new ol . style . Icon ( ( {
173- anchor : [ markers . size [ 0 ] / 2 , markers . size [ 1 ] ] ,
136+ anchor : [ 12 , 12 ] ,
174137 anchorXUnits : 'pixels' ,
175138 anchorYUnits : 'pixels' ,
176139 src : extraMarkerShadow
@@ -188,8 +151,7 @@ function getMarkerStyle(options) {
188151 text : glyphs [ options . style . iconGlyph ] ,
189152 font : '14px FontAwesome' ,
190153 offsetY : - markers . size [ 1 ] * 2 / 3 ,
191- fill : new ol . style . Fill ( { color : '#FFFFFF' } ) ,
192- stroke : new ol . style . Stroke ( { color : '#FFFFFF' , width : 2 } )
154+ fill : new ol . style . Fill ( { color : '#FFFFFF' } )
193155 } )
194156 } ) ] ;
195157 }
0 commit comments