@@ -593,7 +593,7 @@ angular.module("leaflet-directive").directive('bounds', function ($log, leafletH
593593 } ;
594594} ) ;
595595
596- angular . module ( "leaflet-directive" ) . directive ( 'markers' , function ( $log , $rootScope , $q , leafletData , leafletHelpers , leafletMapDefaults , leafletEvents ) {
596+ angular . module ( "leaflet-directive" ) . directive ( 'markers' , function ( $log , $rootScope , $q , leafletData , leafletHelpers , leafletMapDefaults , leafletMarkerHelpers , leafletEvents ) {
597597 return {
598598 restrict : "A" ,
599599 scope : false ,
@@ -611,11 +611,11 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
611611 safeApply = leafletHelpers . safeApply ,
612612 leafletScope = mapController . getLeafletScope ( ) ,
613613 markers = leafletScope . markers ,
614+ getLeafletIcon = leafletMarkerHelpers . getLeafletIcon ,
614615 availableMarkerEvents = leafletEvents . getAvailableMarkerEvents ( ) ;
615616
616617 mapController . getMap ( ) . then ( function ( map ) {
617- var defaults = leafletMapDefaults . getDefaults ( attrs . id ) ,
618- leafletMarkers = { } ,
618+ var leafletMarkers = { } ,
619619 groups = { } ,
620620 getLayers ;
621621
@@ -629,22 +629,6 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
629629 } ;
630630 }
631631
632- // Default leaflet icon object used in all markers as a default
633- var LeafletIcon = L . Icon . extend ( {
634- options : {
635- iconUrl : defaults . icon . url ,
636- iconRetinaUrl : defaults . icon . retinaUrl ,
637- iconSize : defaults . icon . size ,
638- iconAnchor : defaults . icon . anchor ,
639- labelAnchor : defaults . icon . labelAnchor ,
640- popupAnchor : defaults . icon . popup ,
641- shadowUrl : defaults . icon . shadow . url ,
642- shadowRetinaUrl : defaults . icon . shadow . retinaUrl ,
643- shadowSize : defaults . icon . shadow . size ,
644- shadowAnchor : defaults . icon . shadow . anchor
645- }
646- } ) ;
647-
648632 if ( ! isDefined ( markers ) ) {
649633 return ;
650634 }
@@ -1034,7 +1018,7 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
10341018 // If there is no icon property or it's not an object
10351019 if ( old_data . icon !== undefined && old_data . icon !== null && typeof old_data . icon === 'object' ) {
10361020 // If there was an icon before restore to the default
1037- marker . setIcon ( new LeafletIcon ( ) ) ;
1021+ marker . setIcon ( getLeafletIcon ( ) ) ;
10381022 marker . closePopup ( ) ;
10391023 marker . unbindPopup ( ) ;
10401024 if ( data . message !== undefined && data . message !== null && typeof data . message === 'string' && data . message !== "" ) {
@@ -1056,7 +1040,7 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
10561040 marker . setIcon ( data . icon ) ;
10571041 } else {
10581042 // This icon is a icon set in the model trough options
1059- marker . setIcon ( new LeafletIcon ( data . icon ) ) ;
1043+ marker . setIcon ( getLeafletIcon ( data . icon ) ) ;
10601044 }
10611045 if ( dragA ) {
10621046 marker . dragging . enable ( ) ;
@@ -1132,7 +1116,7 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
11321116 if ( marker . dragging ) {
11331117 dragG = marker . dragging . enabled ( ) ;
11341118 }
1135- marker . setIcon ( new LeafletIcon ( data . icon ) ) ;
1119+ marker . setIcon ( getLeafletIcon ( data . icon ) ) ;
11361120 if ( dragG ) {
11371121 marker . dragging . enable ( ) ;
11381122 }
@@ -1236,7 +1220,7 @@ angular.module("leaflet-directive").directive('markers', function ($log, $rootSc
12361220 if ( data . icon ) {
12371221 micon = data . icon ;
12381222 } else {
1239- micon = new LeafletIcon ( ) ;
1223+ micon = getLeafletIcon ( ) ;
12401224 }
12411225 var moptions = {
12421226 icon : micon ,
@@ -1692,20 +1676,6 @@ angular.module("leaflet-directive").factory('leafletMapDefaults', function ($q,
16921676 tileLayerOptions : {
16931677 attribution : '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
16941678 } ,
1695- icon : {
1696- url : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-icon.png' ,
1697- retinaUrl : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-icon-2x.png' ,
1698- size : [ 25 , 41 ] ,
1699- anchor : [ 12 , 40 ] ,
1700- labelAnchor : [ 10 , - 20 ] ,
1701- popup : [ 0 , - 40 ] ,
1702- shadow : {
1703- url : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-shadow.png' ,
1704- retinaUrl : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-shadow.png' ,
1705- size : [ 41 , 41 ] ,
1706- anchor : [ 12 , 40 ]
1707- }
1708- } ,
17091679 path : {
17101680 weight : 10 ,
17111681 opacity : 1 ,
@@ -1775,7 +1745,7 @@ angular.module("leaflet-directive").factory('leafletMapDefaults', function ($q,
17751745 newDefaults . zoomControlPosition = isDefined ( userDefaults . zoomControlPosition ) ? userDefaults . zoomControlPosition : newDefaults . zoomControlPosition ;
17761746 newDefaults . keyboard = isDefined ( userDefaults . keyboard ) ? userDefaults . keyboard : newDefaults . keyboard ;
17771747 newDefaults . dragging = isDefined ( userDefaults . dragging ) ? userDefaults . dragging : newDefaults . dragging ;
1778-
1748+
17791749 newDefaults . controlLayersPosition = isDefined ( userDefaults . controlLayersPosition ) ? userDefaults . controlLayersPosition : newDefaults . controlLayersPosition ;
17801750
17811751 if ( isDefined ( userDefaults . crs ) && isDefined ( L . CRS [ userDefaults . crs ] ) ) {
@@ -1923,7 +1893,7 @@ angular.module("leaflet-directive").factory('leafletEvents', function ($rootScop
19231893} ) ;
19241894
19251895
1926- angular . module ( "leaflet-directive" ) . factory ( 'leafletLayerHelpers' , function ( $rootScope , $q , $ log, leafletHelpers ) {
1896+ angular . module ( "leaflet-directive" ) . factory ( 'leafletLayerHelpers' , function ( $rootScope , $log , leafletHelpers ) {
19271897 var Helpers = leafletHelpers ,
19281898 isString = leafletHelpers . isString ,
19291899 isObject = leafletHelpers . isObject ,
@@ -2096,6 +2066,33 @@ angular.module("leaflet-directive").factory('leafletLayerHelpers', function ($ro
20962066 } ;
20972067} ) ;
20982068
2069+ angular . module ( "leaflet-directive" ) . factory ( 'leafletMarkerHelpers' , function ( ) {
2070+
2071+ var LeafletDefaultIcon = L . Icon . extend ( {
2072+ options : {
2073+ iconUrl : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-icon.png' ,
2074+ iconRetinaUrl : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-icon-2x.png' ,
2075+ iconSize : [ 25 , 41 ] ,
2076+ iconAnchor : [ 12 , 40 ] ,
2077+ labelAnchor : [ 10 , - 20 ] ,
2078+ popupAnchor : [ 0 , - 40 ] ,
2079+ shadow : {
2080+ url : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-shadow.png' ,
2081+ retinaUrl : 'http://cdn.leafletjs.com/leaflet-0.7/images/marker-shadow.png' ,
2082+ size : [ 41 , 41 ] ,
2083+ anchor : [ 12 , 40 ]
2084+ }
2085+ }
2086+ } ) ;
2087+
2088+ return {
2089+ getLeafletIcon : function ( data ) {
2090+ return new LeafletDefaultIcon ( data ) ;
2091+ }
2092+ } ;
2093+
2094+ } ) ;
2095+
20992096angular . module ( "leaflet-directive" ) . factory ( 'leafletHelpers' , function ( $q , $log ) {
21002097
21012098 function _obtainEffectiveMapId ( d , mapId ) {
0 commit comments