1- import L from ' leaflet' ;
1+ import L from " leaflet" ;
22
3- import ' ../images/marker-green.png' ;
4- import ' ../images/marker-red.png' ;
5- import ' ../images/marker-shadow.png' ;
3+ import " ../images/marker-green.png" ;
4+ import " ../images/marker-red.png" ;
5+ import " ../images/marker-shadow.png" ;
66
77const MapService = ( $http ) => {
88 const service = {
99 getCity,
1010 getMapIcon,
11- getMapInstance,
11+ getMapInstance
1212 } ;
1313
1414 return service ;
@@ -17,101 +17,107 @@ const MapService = ($http) => {
1717
1818 function getCity ( name ) {
1919 return $http ( {
20- method : ' GET' ,
21- url : ' //nominatim.openstreetmap.org/search' ,
20+ method : " GET" ,
21+ url : " //nominatim.openstreetmap.org/search" ,
2222 params : {
23- format : ' json' ,
23+ format : " json" ,
2424 q : name ,
25- dedupe : 1 ,
26- } ,
25+ dedupe : 1
26+ }
2727 } ) ;
2828 }
2929
3030 function getMapIcon ( options ) {
3131 return {
32- iconUrl : `assets/images/marker-${ options && options . image ? 'green' : 'red' } .png` ,
33- shadowUrl : 'assets/images/marker-shadow.png' ,
32+ iconUrl : `assets/images/marker-${
33+ options && options . image ? "green" : "red"
34+ } .png`,
35+ shadowUrl : "assets/images/marker-shadow.png" ,
3436 iconSize : [ 29 , 41 ] ,
3537 shadowSize : [ 41 , 41 ] ,
3638 iconAnchor : [ 15 , 41 ] ,
3739 shadowAnchor : [ 12 , 41 ] ,
38- popupAnchor : [ 0 , - 43 ] ,
40+ popupAnchor : [ 0 , - 43 ]
3941 } ;
4042 }
4143
4244 function getMapInstance ( options ) {
43- return angular . extend ( {
44- markersWatchOptions : {
45- doWatch : true ,
46- isDeep : false ,
47- individual : {
48- doWatch : false ,
45+ return angular . extend (
46+ {
47+ markersWatchOptions : {
48+ doWatch : true ,
4949 isDeep : false ,
50+ individual : {
51+ doWatch : false ,
52+ isDeep : false
53+ }
5054 } ,
51- } ,
52- center : {
53- lat : 51.686 ,
54- lng : 19.545 ,
55- zoom : 7 ,
56- } ,
57- markers : { } ,
58- events : {
59- markers : {
60- enable : [ 'click' , 'mouseover' , 'mouseout' ] ,
55+ center : {
56+ lat : 51.686 ,
57+ lng : 19.545 ,
58+ zoom : 7
6159 } ,
62- } ,
63- layers : {
64- baselayers : {
65- wiki : {
66- name : 'Wikimedia Maps' ,
67- type : 'xyz' ,
68- url : '//maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png' ,
69- layerOptions : {
70- subdomains : [ 'a' , 'b' , 'c' ] ,
71- attribution : '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
72- continuousWorld : true ,
73- maxNativeZoom : 18 ,
74- maxZoom : 21 ,
75- } ,
76- } ,
77- osm : {
78- name : 'OpenStreetMap' ,
79- type : 'xyz' ,
80- url : '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' ,
81- layerOptions : {
82- subdomains : [ 'a' , 'b' , 'c' ] ,
83- attribution : '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
84- continuousWorld : true ,
85- maxNativeZoom : 19 ,
86- maxZoom : 21 ,
87- } ,
88- } ,
60+ markers : { } ,
61+ events : {
62+ markers : {
63+ enable : [ "click" , "mouseover" , "mouseout" ]
64+ }
8965 } ,
90- overlays : {
91- monuments : {
92- name : 'Monuments' ,
93- type : 'markercluster' ,
94- visible : true ,
95- layerOptions : {
96- showCoverageOnHover : false ,
97- zoomToBoundsOnClick : true ,
98- maxClusterRadius : zoom => 130 - ( zoom * 5 ) ,
99- animate : false ,
100- iconCreateFunction : cluster => new L . DivIcon ( {
101- html : `<div><span>${ cluster . getChildCount ( ) } </span></div>` ,
102- className : 'marker-cluster marker-cluster-small' ,
103- iconSize : new L . Point ( 40 , 40 ) ,
104- } ) ,
66+ layers : {
67+ baselayers : {
68+ wiki : {
69+ name : "Wikimedia Maps" ,
70+ type : "xyz" ,
71+ url : "//maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png" ,
72+ layerOptions : {
73+ subdomains : [ "a" , "b" , "c" ] ,
74+ attribution :
75+ '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
76+ continuousWorld : true ,
77+ maxNativeZoom : 18 ,
78+ maxZoom : 21
79+ }
10580 } ,
81+ osm : {
82+ name : "OpenStreetMap" ,
83+ type : "xyz" ,
84+ url : "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" ,
85+ layerOptions : {
86+ subdomains : [ "a" , "b" , "c" ] ,
87+ attribution :
88+ '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' ,
89+ continuousWorld : true ,
90+ maxNativeZoom : 19 ,
91+ maxZoom : 21
92+ }
93+ }
10694 } ,
107- } ,
95+ overlays : {
96+ monuments : {
97+ name : "Monuments" ,
98+ type : "markercluster" ,
99+ visible : true ,
100+ layerOptions : {
101+ showCoverageOnHover : false ,
102+ zoomToBoundsOnClick : true ,
103+ maxClusterRadius : ( zoom ) => 130 - zoom * 5 ,
104+ animate : false ,
105+ iconCreateFunction : ( cluster ) =>
106+ new L . DivIcon ( {
107+ html : `<div><span>${ cluster . getChildCount ( ) } </span></div>` ,
108+ className : "marker-cluster marker-cluster-small" ,
109+ iconSize : new L . Point ( 40 , 40 )
110+ } )
111+ }
112+ }
113+ }
114+ }
108115 } ,
109- } , options ) ;
116+ options
117+ ) ;
110118 }
111119} ;
112120
113121export default ( ) => {
114- angular
115- . module ( 'monumental' )
116- . factory ( 'mapService' , MapService ) ;
122+ angular . module ( "monumental" ) . factory ( "mapService" , MapService ) ;
117123} ;
0 commit comments