@@ -2,24 +2,34 @@ import _ from 'lodash'
2
2
import L from 'leaflet'
3
3
import { utils as coreUtils } from '../../../core/client/index.js'
4
4
5
+ // Defaults marker properties
6
+ const defaults = {
7
+ shape : 'marker-pin' ,
8
+ width : 28 ,
9
+ height : 36 ,
10
+ icon : {
11
+ classes : 'fa fa-circle'
12
+ }
13
+ }
14
+
5
15
export const ShapeMarker = L . Marker . extend ( {
6
16
initialize ( latlng , options ) {
7
- // set default values
8
- const shape = _ . get ( options , 'shape' , 'marker-pin' )
9
- const width = _ . get ( options , 'width' , 28 )
10
- const height = _ . get ( options , 'height' , 36 )
11
- // create divicon
12
- var icon = L . divIcon ( {
13
- iconSize : [ width , height ] ,
14
- iconAnchor : [ width / 2 , height ] ,
15
- html : coreUtils . createShape ( Object . assign ( { shape, width, height } , options ) ) ,
16
- className : 'dummy'
17
+ let _options = _ . cloneDeep ( options )
18
+ // map options from simplespec to SVG shape
19
+ if ( _options . fillColor ) _ . set ( _options , 'color' , options . fillColor )
20
+ if ( _options . fillOpacity ) _ . set ( _options , 'opacity' , options . fillOpacity )
21
+ if ( _options . color ) _ . set ( _options , 'stroke.color' , options . color )
22
+ if ( _options . weight ) _ . set ( _options , 'stroke.Width' , options . weight )
23
+ // create the marker with the corredt divIcon
24
+ const width = _options . width || defaults . width
25
+ const height = _options . height || defaults . height
26
+ L . Marker . prototype . initialize . call ( this , latlng , {
27
+ icon : L . divIcon ( {
28
+ iconSize : [ width , height ] ,
29
+ iconAnchor : [ width / 2 , height ] ,
30
+ html : coreUtils . createShape ( _ . defaultsDeep ( _options , defaults ) ) ,
31
+ className : ''
32
+ } )
17
33
} )
18
- // this.enableDebug = true
19
- L . Marker . prototype . initialize . call ( this , latlng , { icon } )
20
34
}
21
35
} )
22
-
23
- L . shapeMarker = function ( latlng , options ) {
24
- return new ShapeMarker ( latlng , options )
25
- }
0 commit comments