-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT_fcoo-havnelods.js
More file actions
227 lines (179 loc) · 7.36 KB
/
Copy pathYT_fcoo-havnelods.js
File metadata and controls
227 lines (179 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/****************************************************************************
fcoo-havnelods.js,
(c) 2021, FCOO
https://github.com/FCOO/fcoo-havnelods
https://github.com/FCOO
****************************************************************************/
(function ($, L, i18next, moment, window/*, document, undefined*/) {
"use strict";
window.fcoo = window.fcoo || {};
var ns = window.fcoo = window.fcoo || {},
nsHL = ns.Havnelods = ns.Havnelods || {};
//Internal method to set width of buttons
nsHL._getSizeClass = function(small){
if (small === true) return 'min-width-5em';
if (small === false) return 'min-width-8em';
return null;
};
/**********************************************************************
L.GeoJSON.Havnelods(options)
Generel constructor for all variations
***********************************************************************/
L.GeoJSON.Havnelods = L.GeoJSON.extend({
//Default options
options: {
idName : 'HAVNE_ID',
subDir : 'havnelods',
fileName : 'havnelods.json',
images : 'images',
annotationId : 'ANMERKNING',
annotationClass : 'hl-annotation alert-info accordion-body accordion'
},
locationConstructor: null,
/*********************************************
initialize
*********************************************/
initialize: function(geojson, options = {}) {
options = $.extend(true, {}, {
pointToLayer : $.proxy(this.pointToLayer, this),
onEachFeature: $.proxy(this.onEachFeature, this),
}, options);
L.GeoJSON.prototype.initialize.call(this, geojson, options);
// HER> var _this = this;
this.addContextmenuItems([ this.buttonShowAll() ])
//Load and add geoJSON-data
this.list = [];
window.Promise.getJSON(
ns.dataFilePath({mainDir: true, subDir: this.options.subDir, fileName: this.options.fileName}),
{},
$.proxy(this.resolve, this)
);
},
/*********************************************
resolve
*********************************************/
resolve: function(data){
//data = []LOCATION
var _this = this,
geoJSONData = {
type : "FeatureCollection",
features: []
};
this.list = [];
data.forEach((options) => {
/*TEST: Only Langebro
if (options.BRO_ID != '7d17393b-3e61-4157-be25-b8861a78b9ad')
return false;
//*/
var location = new _this.locationConstructor(options, _this);
location.index = _this.list.length;
_this.list.push(location);
if (location.latLng)
geoJSONData.features.push({
type : "Feature",
geometry : {type: "Point", coordinates: [location.latLng.lng, location.latLng.lat]},
properties: location
});
});
this.addData(geoJSONData);
},
/*********************************************
pointToLayer
*********************************************/
pointToLayer: function(geoJSONPoint){
return geoJSONPoint.properties.createMarker();
},
/*********************************************
onEachFeature - Add context-menu-items
*********************************************/
onEachFeature: function(feature, element){
var loc = feature.properties;
element
.setContextmenuHeader(loc.header, true)
.setContextmenuWidth( '8em' )
.addContextmenuItems([
loc.buttonShow(),
loc.buttonGST(1),
])
.setContextmenuParent(loc.parent);
/*
var message = featureMessage( feature );
element
.addContextmenuItems([
message.bsHeaderOptions('SMALL'),
{
icon : 'fa-window-maximize',
text : {da:'Vis...', en:'Show...'},
width: 120,
onClick: $.proxy(message.asModal, message)
}
])
.setContextmenuParent(message.messages);
*/
},
/*********************************************
buttonShowAll
*********************************************/
buttonShowAll: function( small ){
return {
icon : 'fa-th-list',
text : {da:'Vis alle', en:'Show all'},
class : nsHL._getSizeClass(small),
onClick: this.asModal.bind(this)
};
},
/*********************************************
asModal
*********************************************/
asModal: function(options){
if (this.bsModal)
this.bsModal.close();
console.log('LIST=', this.list);
},
/*********************************************
MANGLER
*********************************************/
MANGLER: function(){
},
});
//Extend Niord.Messages to include contextmenu
$.extend(L.GeoJSON.Havnelods.prototype, L.BsContextmenu.contextmenuInclude);
/**********************************************************************
***********************************************************************
L.GeoJSON.Havnelods_DK(options)
GeoJSON-layer with danish harbors
***********************************************************************
**********************************************************************/
L.GeoJSON.Havnelods_DK = L.GeoJSON.Havnelods.extend({
options: {
fileName: 'havnelods_DK.json'
},
locationConstructor: nsHL.Location_DK
});
/*********************************************************************
**********************************************************************
L.GeoJSON.Havnelods_GL(options)
GeoJSON-layer with Greenlandic towns, hamlets, and stations
**********************************************************************
**********************************************************************/
L.GeoJSON.Havnelods_GL = L.GeoJSON.Havnelods.extend({
options: {
fileName: 'havnelods_GL.json'
},
locationConstructor: nsHL.Location_GL
});
/*********************************************************************
**********************************************************************
L.GeoJSON.Havnelods_Bridges(options)
GeoJSON-layer with danish bridges
**********************************************************************
**********************************************************************/
L.GeoJSON.Havnelods_Bridges = L.GeoJSON.Havnelods.extend({
options: {
idName : 'BRO_ID',
fileName : 'havnelods_BR.json',
planHeader: {da:'Broplan'/*, en:'MANGLER'*/}
},
locationConstructor: nsHL.Location_Bridges
});
}(jQuery, L, this.i18next, this.moment, this, document));