web-mapping-leaflet 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,206 @@
1
+ /*
2
+ Leaflet.BeautifyIcon, a plugin that adds colorful iconic markers for Leaflet by giving full control of style to end user, It has also ability to adjust font awesome
3
+ and glyphicon icons
4
+ (c) 2016-2017, Muhammad Arslan Sajid
5
+ http://leafletjs.com
6
+ */
7
+
8
+ /*global L of leaflet*/
9
+
10
+ (function (window, document, undefined) {
11
+
12
+ 'use strict';
13
+
14
+ /*
15
+ * Leaflet.BeautifyIcon assumes that you have already included the Leaflet library.
16
+ */
17
+
18
+ /*
19
+ * Default settings for various style markers
20
+ */
21
+ var defaults = {
22
+
23
+ iconColor: '#1EB300',
24
+
25
+ iconAnchor: {
26
+ 'marker': [14, 36]
27
+ , 'circle': [11, 10]
28
+ , 'circle-dot': [5, 5]
29
+ , 'rectangle-dot': [5, 6]
30
+ , 'doughnut': [8, 8]
31
+ },
32
+
33
+ popupAnchor: {
34
+ 'marker': [0, -25]
35
+ , 'circle': [-3, -76]
36
+ , 'circle-dot': [0, -2]
37
+ , 'rectangle-dot': [0, -2]
38
+ , 'doughnut': [0, -2]
39
+ },
40
+
41
+ innerIconAnchor: {
42
+ 'marker': [-2, 5]
43
+ , 'circle': [0, 2]
44
+ },
45
+
46
+ iconSize: {
47
+ 'marker': [28, 28]
48
+ , 'circle': [22, 22]
49
+ , 'circle-dot': [2, 2]
50
+ , 'rectangle-dot': [2, 2]
51
+ , 'doughnut': [15, 15]
52
+ }
53
+ };
54
+
55
+ L.BeautifyIcon = {
56
+
57
+ Icon: L.Icon.extend({
58
+
59
+ options: {
60
+ icon: 'leaf'
61
+ , iconSize: defaults.iconSize.circle
62
+ , iconAnchor: defaults.iconAnchor.circle
63
+ , iconShape: 'circle'
64
+ , iconStyle: ''
65
+ , innerIconAnchor: [0, 3] // circle with fa or glyphicon or marker with text
66
+ , innerIconStyle: ''
67
+ , isAlphaNumericIcon: false
68
+ , text: 1
69
+ , borderColor: defaults.iconColor
70
+ , borderWidth: 2
71
+ , borderStyle: 'solid'
72
+ , backgroundColor: 'white'
73
+ , textColor: defaults.iconColor
74
+ , customClasses: ''
75
+ , spin: false
76
+ , prefix: 'fa'
77
+ , html: ''
78
+ },
79
+
80
+ initialize: function (options) {
81
+
82
+ this.applyDefaults(options);
83
+ this.options = (!options || !options.html) ? L.Util.setOptions(this, options) : options;
84
+ },
85
+
86
+ applyDefaults: function (options) {
87
+
88
+ if (options) {
89
+ if (!options.iconSize && options.iconShape) {
90
+ options.iconSize = defaults.iconSize[options.iconShape];
91
+ }
92
+
93
+ if (!options.iconAnchor && options.iconShape) {
94
+ options.iconAnchor = defaults.iconAnchor[options.iconShape];
95
+ }
96
+
97
+ if (!options.popupAnchor && options.iconShape) {
98
+ options.popupAnchor = defaults.popupAnchor[options.iconShape];
99
+ }
100
+
101
+ if (!options.innerIconAnchor) {
102
+ // if icon is type of circle or marker
103
+ if (options.iconShape === 'circle' || options.iconShape === 'marker') {
104
+ if (options.iconShape === 'circle' && options.isAlphaNumericIcon) { // if circle with text
105
+ options.innerIconAnchor = [0, -1];
106
+ }
107
+ else if (options.iconShape === 'marker' && !options.isAlphaNumericIcon) {// marker with icon
108
+ options.innerIconAnchor = defaults.innerIconAnchor[options.iconShape];
109
+ }
110
+ }
111
+ }
112
+ }
113
+ },
114
+
115
+ createIcon: function () {
116
+
117
+ var iconDiv = document.createElement('div')
118
+ , options = this.options;
119
+
120
+ iconDiv.innerHTML = !options.html ? this.createIconInnerHtml() : options.html;
121
+ this._setIconStyles(iconDiv);
122
+
123
+ // having a marker requires an extra parent div for rotation correction
124
+ if (this.options.iconShape === 'marker') {
125
+ var wrapperDiv = document.createElement('div');
126
+ wrapperDiv.className = 'beautify-marker';
127
+ wrapperDiv.appendChild(iconDiv);
128
+ return wrapperDiv;
129
+ }
130
+
131
+ return iconDiv;
132
+ },
133
+
134
+ createIconInnerHtml: function () {
135
+
136
+ var options = this.options;
137
+
138
+ if (options.iconShape === 'circle-dot' || options.iconShape === 'rectangle-dot' || options.iconShape === 'doughnut') {
139
+ return '';
140
+ }
141
+
142
+ var innerIconStyle = this.getInnerIconStyle(options);
143
+ if (options.isAlphaNumericIcon) {
144
+ return '<div style="' + innerIconStyle + '">' + options.text + '</div>';
145
+ }
146
+
147
+ var spinClass = '';
148
+ if (options.spin) {
149
+ spinClass = ' fa-spin';
150
+ }
151
+
152
+ return '<i class="' + options.prefix + ' ' + options.prefix + '-' + options.icon + spinClass + '" style="' + innerIconStyle + '"></i>';
153
+ },
154
+
155
+ getInnerIconStyle: function (options) {
156
+
157
+ var innerAnchor = L.point(options.innerIconAnchor)
158
+ return 'color:' + options.textColor + ';margin-top:' + innerAnchor.y + 'px; margin-left:' + innerAnchor.x + 'px;' + options.innerIconStyle;
159
+ },
160
+
161
+ _setIconStyles: function (iconDiv) {
162
+
163
+ var options = this.options
164
+ , size = L.point(options.iconSize)
165
+ , anchor = L.point(options.iconAnchor);
166
+
167
+ iconDiv.className = 'beautify-marker ';
168
+
169
+ if (options.iconShape) {
170
+ iconDiv.className += options.iconShape;
171
+ }
172
+
173
+ if (options.customClasses) {
174
+ iconDiv.className += ' ' + options.customClasses;
175
+ }
176
+
177
+ iconDiv.style.backgroundColor = options.backgroundColor;
178
+ iconDiv.style.color = options.textColor;
179
+ iconDiv.style.borderColor = options.borderColor;
180
+ iconDiv.style.borderWidth = options.borderWidth + 'px';
181
+ iconDiv.style.borderStyle = options.borderStyle;
182
+
183
+ if (size) {
184
+ iconDiv.style.width = size.x + 'px';
185
+ iconDiv.style.height = size.y + 'px';
186
+ }
187
+
188
+ if (anchor) {
189
+ iconDiv.style.marginLeft = (-anchor.x) + 'px';
190
+ iconDiv.style.marginTop = (-anchor.y) + 'px';
191
+ }
192
+
193
+ if (options.iconStyle) {
194
+ var cStyle = iconDiv.getAttribute('style');
195
+ cStyle += options.iconStyle;
196
+ iconDiv.setAttribute('style', cStyle);
197
+ }
198
+ }
199
+ })
200
+ };
201
+
202
+ L.BeautifyIcon.icon = function (options) {
203
+ return new L.BeautifyIcon.Icon(options);
204
+ }
205
+
206
+ }(this, document));
@@ -1,8 +1,8 @@
1
- {
2
- "type": "FeatureCollection",
3
- "name": "polyline",
4
- "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5
- "features": [
6
- { "type": "Feature", "properties": { "id": 1, "Remark": "Just a route" }, "geometry": { "type": "LineString", "coordinates": [ [ -9.048305, 39.755093 ], [ -20.094827002741617, 33.113108009574347 ], [ -25.840755341503833, 20.389980973743732 ], [ -25.019908435966371, 8.077277390681843 ], [ -18.453133191666698, 2.741772504688356 ], [ -12.091569673751387, 0.484443514460338 ], [ -8.192546872448453, 0.894866967229063 ], [ 9.830284, 1.067894 ], [ 9.830284, 1.067894 ], [ -1.215348175380051, -8.750084172836083 ], [ 0.631557362079228, -25.987869189122733 ], [ 8.429602964685095, -32.349432707038034 ], [ 11.712990586834934, -33.375491338959847 ], [ 15.201589935369135, -33.785914791728601 ], [ 19.193278, -34.462599 ], [ 29.976834235043405, -41.994383847103194 ], [ 45.367713713870764, -38.710996224953334 ], [ 51.113642052632976, -35.427608602803502 ], [ 53.165759316476631, -32.965067886191122 ], [ 55.423088306704635, -30.297315443194378 ], [ 60.758593192698122, -28.03998645296636 ], [ 81.787959, 7.523055 ], [ 100.085757, 6.464489 ] ] } }
7
- ]
8
- }
1
+ {
2
+ "type": "FeatureCollection",
3
+ "name": "polyline",
4
+ "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5
+ "features": [
6
+ { "type": "Feature", "properties": { "id": 1, "Remark": "Just a route" }, "geometry": { "type": "LineString", "coordinates": [ [ -9.048305, 39.755093 ], [ -20.094827002741617, 33.113108009574347 ], [ -25.840755341503833, 20.389980973743732 ], [ -25.019908435966371, 8.077277390681843 ], [ -18.453133191666698, 2.741772504688356 ], [ -12.091569673751387, 0.484443514460338 ], [ -8.192546872448453, 0.894866967229063 ], [ 9.830284, 1.067894 ], [ 9.830284, 1.067894 ], [ -1.215348175380051, -8.750084172836083 ], [ 0.631557362079228, -25.987869189122733 ], [ 8.429602964685095, -32.349432707038034 ], [ 11.712990586834934, -33.375491338959847 ], [ 15.201589935369135, -33.785914791728601 ], [ 19.193278, -34.462599 ], [ 29.976834235043405, -41.994383847103194 ], [ 45.367713713870764, -38.710996224953334 ], [ 51.113642052632976, -35.427608602803502 ], [ 53.165759316476631, -32.965067886191122 ], [ 55.423088306704635, -30.297315443194378 ], [ 60.758593192698122, -28.03998645296636 ], [ 81.787959, 7.523055 ], [ 100.085757, 6.464489 ] ] } }
7
+ ]
8
+ }