|
8 | 8 | <script src="../dist/angular-leaflet-directive.js"></script> |
9 | 9 | <link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" /> |
10 | 10 | <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css"> |
11 | | - <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> |
| 11 | + <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"> |
12 | 12 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
13 | 13 | <script> |
14 | 14 | var app = angular.module("demoapp", ["leaflet-directive"]); |
15 | | - app.controller('ControlsCustomLayerControlController', [ '$scope', function($scope) { |
| 15 | + app.controller("ControlsCustomLayerControlController", [ "$scope", function($scope) { |
16 | 16 | angular.extend($scope, { |
| 17 | + layercontrol: { |
| 18 | + icons: { |
| 19 | + uncheck: "fa fa-toggle-off", |
| 20 | + check: "fa fa-toggle-on" |
| 21 | + } |
| 22 | + }, |
17 | 23 | ripoll: { |
18 | 24 | lat: 42.20133, |
19 | 25 | lng: 2.19110, |
|
28 | 34 | layers: { |
29 | 35 | baselayers: { |
30 | 36 | osm: { |
31 | | - name: 'OpenStreetMap', |
32 | | - type: 'xyz', |
33 | | - url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 37 | + name: "OpenStreetMap", |
| 38 | + type: "xyz", |
| 39 | + url: "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", |
34 | 40 | layerOptions: { |
35 | | - subdomains: ['a', 'b', 'c'], |
36 | | - attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 41 | + subdomains: ["a", "b", "c"], |
| 42 | + attribution: "© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors", |
37 | 43 | continuousWorld: true |
38 | 44 | } |
39 | 45 | }, |
40 | 46 | cycle: { |
41 | | - name: 'OpenCycleMap', |
42 | | - type: 'xyz', |
43 | | - url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', |
| 47 | + name: "OpenCycleMap", |
| 48 | + type: "xyz", |
| 49 | + url: "http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png", |
44 | 50 | layerOptions: { |
45 | | - subdomains: ['a', 'b', 'c'], |
46 | | - attribution: '© <a href="http://www.opencyclemap.org/copyright">OpenCycleMap</a> contributors - © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 51 | + subdomains: ["a", "b", "c"], |
| 52 | + attribution: "© <a href=\"http://www.opencyclemap.org/copyright\">OpenCycleMap</a> contributors - © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors", |
47 | 53 | continuousWorld: true |
48 | 54 | } |
49 | 55 | } |
50 | 56 | }, |
51 | 57 | overlays: { |
52 | 58 | hillshade: { |
53 | | - name: 'Hillshade Europa', |
54 | | - type: 'wms', |
55 | | - url: 'http://129.206.228.72/cached/hillshade', |
| 59 | + name: "Hillshade Europa", |
| 60 | + type: "wms", |
| 61 | + url: "http://129.206.228.72/cached/hillshade", |
56 | 62 | visible: true, |
57 | 63 | layerOptions: { |
58 | | - layers: 'europe_wms:hs_srtm_europa', |
59 | | - format: 'image/png', |
| 64 | + layers: "europe_wms:hs_srtm_europa", |
| 65 | + format: "image/png", |
60 | 66 | opacity: 0.25, |
61 | | - attribution: 'Hillshade layer by GIScience http://www.osm-wms.de', |
| 67 | + attribution: "Hillshade layer by GIScience http://www.osm-wms.de", |
62 | 68 | crs: L.CRS.EPSG900913 |
63 | 69 | } |
64 | 70 | }, |
65 | 71 | fire: { |
66 | | - name: 'OpenFireMap', |
67 | | - type: 'xyz', |
68 | | - url: 'http://openfiremap.org/hytiles/{z}/{x}/{y}.png', |
| 72 | + name: "OpenFireMap", |
| 73 | + type: "xyz", |
| 74 | + url: "http://openfiremap.org/hytiles/{z}/{x}/{y}.png", |
69 | 75 | layerOptions: { |
70 | | - attribution: '© <a href="http://www.openfiremap.org">OpenFireMap</a> contributors - © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 76 | + attribution: "© <a href=\"http://www.openfiremap.org\">OpenFireMap</a> contributors - © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors", |
71 | 77 | continuousWorld: true |
72 | 78 | } |
73 | 79 | } |
|
78 | 84 | }, |
79 | 85 | addFireLayer: function() { |
80 | 86 | this.layers.overlays.fire = { |
81 | | - name: 'OpenFireMap', |
82 | | - type: 'xyz', |
83 | | - url: 'http://openfiremap.org/hytiles/{z}/{x}/{y}.png', |
| 87 | + name: "OpenFireMap", |
| 88 | + type: "xyz", |
| 89 | + url: "http://openfiremap.org/hytiles/{z}/{x}/{y}.png", |
84 | 90 | layerOptions: { |
85 | | - attribution: '© <a href="http://www.openfiremap.org">OpenFireMap</a> contributors - © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 91 | + attribution: "© <a href=\"http://www.openfiremap.org\">OpenFireMap</a> contributors - © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors", |
86 | 92 | continuousWorld: true |
87 | 93 | } |
88 | 94 | }; |
89 | 95 | }, |
90 | 96 | existsFireLayer: function() { |
91 | | - return ('fire' in this.layers.overlays); |
| 97 | + return ("fire" in this.layers.overlays); |
92 | 98 | }, |
93 | 99 | removeHillshadeLayer: function() { |
94 | 100 | delete this.layers.overlays.hillshade; |
95 | 101 | }, |
96 | 102 | addHillshadeLayer: function() { |
97 | 103 | this.layers.overlays.hillshade = { |
98 | | - name: 'Hillshade Europa', |
99 | | - type: 'wms', |
100 | | - url: 'http://129.206.228.72/cached/hillshade', |
| 104 | + name: "Hillshade Europa", |
| 105 | + type: "wms", |
| 106 | + url: "http://129.206.228.72/cached/hillshade", |
101 | 107 | visible: true, |
102 | 108 | layerOptions: { |
103 | | - layers: 'europe_wms:hs_srtm_europa', |
104 | | - format: 'image/png', |
| 109 | + layers: "europe_wms:hs_srtm_europa", |
| 110 | + format: "image/png", |
105 | 111 | opacity: 0.25, |
106 | | - attribution: 'Hillshade layer by GIScience http://www.osm-wms.de', |
| 112 | + attribution: "Hillshade layer by GIScience http://www.osm-wms.de", |
107 | 113 | crs: L.CRS.EPSG900913 |
108 | 114 | } |
109 | 115 | }; |
110 | 116 | }, |
111 | 117 | existsHillshadeLayer: function() { |
112 | | - return ('hillshade' in this.layers.overlays); |
| 118 | + return ("hillshade" in this.layers.overlays); |
113 | 119 | } |
114 | 120 | }); |
115 | 121 | } ]); |
116 | 122 | </script> |
| 123 | +</head> |
| 124 | +<body ng-controller="ControlsCustomLayerControlController"> |
117 | 125 | <style> |
118 | 126 | .angular-leaflet-control-layers { |
119 | 127 | position: absolute; |
|
128 | 136 |
|
129 | 137 | .angular-leaflet-control-layers .lf-row label { |
130 | 138 | cursor: pointer; |
131 | | - width: 100%; |
132 | | - } |
133 | | - |
134 | | - .angular-leaflet-control-layers .lf-row label .lf-icons { |
135 | | - float: right; |
| 139 | + width: 75%; |
136 | 140 | } |
137 | 141 |
|
138 | | - .angular-leaflet-control-layers .lf-row label .lf-icon { |
| 142 | + .angular-leaflet-control-layers .lf-row .lf-icon { |
139 | 143 | cursor: pointer; |
140 | 144 | float: left; |
141 | 145 | margin-right: 5px; |
|
145 | 149 | .angular-leaflet-control-layers .lf-row label .lf-text { |
146 | 150 | float: left; |
147 | 151 | } |
| 152 | + |
| 153 | + .angular-leaflet-control-layers .lf-row .lf-icons { |
| 154 | + float: right; |
| 155 | + } |
148 | 156 | </style> |
149 | | -</head> |
150 | | -<body ng-controller="ControlsCustomLayerControlController"> |
151 | 157 | <leaflet center="ripoll" layers="layers" height="480px" width="100%"> |
152 | | - <layercontrol order="normal"></layercontrol> |
| 158 | + <layercontrol order="normal" icons="layercontrol.icons"></layercontrol> |
153 | 159 | </leaflet> |
154 | 160 | <h1>Dynamic addition and deletion of Overlays control</h1> |
155 | 161 | <button type="button" class="btn btn-default" ng-click="removeHillshadeLayer()" ng-disabled="!existsHillshadeLayer()">Remove Hillshade Overlay</button> |
|
0 commit comments