-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
325 lines (305 loc) · 13.8 KB
/
index.js
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
var sldPrefix = "http://general.pozi.com/gt_public_styles/sld/";
var servers = {
gt: {
url: "http://basemap{s}.pozi.com/geoserver/wms",
options: { subdomains: "1234" }
},
mq:{
url: "http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpeg",
options: {
attribution: 'Tiles by <a href="http://www.mapquest.com/">MapQuest</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
subdomains: "1234"
}
},
depi: {
url: "http://services.land.vic.gov.au/catalogue/publicproxy/guest/sdm_geoserver/wms",
options: {}
}
};
var layers = {
basemap: { server: servers.mq , options: {tiled:true} }
};
var centers = {
gtHQ: [-37.815933, 144.965785],
woods: [-37.69563, 145.20707],
bay: [-37.8519, 144.92875],
clc: [-37.8269, 144.93085],
pIsl: [-38.518812, 145.330405],
haGa :[-37.14241, 142.52089]
}
// gtHQ: Groundtruth Headquaters
// clc: Citylink Circle, south-west of CBD
// pIsl: Phillip Island
// haGa: Halls Gap
var examples = [
{
title: "Bushfire prone areas in two different styles",
description: "To mark big areas you can either use a transpar style (value:0.3, left) or different marks as slash-lines (right).",
views: [
{ center: centers.gtHQ, zoom: 10, span: 6 },
{ center: centers.gtHQ, zoom: 10, span: 6 }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:BUILDINGREG.BUSHFIRE_PRONE_AREA", sld: sldPrefix + "sii-BUILDINGREG.BUSHFIRE_PRONE_AREA.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:BUILDINGREG.BUSHFIRE_PRONE_AREA", sld: sldPrefix + "sii-BUILDINGREG.BUSHFIRE_PRONE_AREA_GEN.sld" } } ]
]
},
{
description: "Here you can see how the style changes with the different zoom levels.",
views: [
{ center: centers.gtHQ, zoom: 7, span: 4 },
{ center: centers.gtHQ, zoom: 10, span: 4 },
{ center: centers.woods, zoom: 17, span: 4 }
],
layers: [
[layers.basemap, layers.bushfireProneAreaGen = { server: servers.depi, options: { layers: "sii:BUILDINGREG.BUSHFIRE_PRONE_AREA", sld: sldPrefix + "sii-BUILDINGREG.BUSHFIRE_PRONE_AREA_GEN.sld" } } ],
[layers.basemap, layers.bushfireProneAreaGen ],
[layers.basemap, layers.bushfireProneAreaGen ]
]
},
{
title: "Public transport - Stops",
description: "Here you see how we styled train, tram and bus stops.",
views: [
{ center: centers.gtHQ, zoom: 10, span: 4, attribution: "Before" },
{ center: centers.gtHQ, zoom: 10, span: 8 }
],
layers: [
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:PTV.PTV_BUS_STOP" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAM_STOP" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAIN_STATION" } }
],
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:PTV.PTV_BUS_STOP", sld: sldPrefix + "sii-PTV.PTV_BUS_STOP.sld" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAM_STOP", sld: sldPrefix + "sii-PTV.PTV_TRAM_STOP.sld" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAIN_STATION", sld: sldPrefix + "sii-PTV.PTV_TRAIN_STATION.sld" } }
]
]
},
{
description: "here you can see tram stops in different zoom levels and how the style is changing",
views: [
{ center: centers.gtHQ, zoom: 10, span: 4 },
{ center: centers.gtHQ, zoom: 14, span: 4 },
{ center: centers.gtHQ, zoom: 18, span: 4 }
],
layers: [
layers.baseAndTramStops = [ layers.basemap, { server: servers.depi, options: { layers: "sii:PTV.PTV_TRAM_STOP", sld: sldPrefix + "sii-PTV.PTV_TRAM_STOP.sld" } } ],
layers.baseAndTramStops,
layers.baseAndTramStops
]
},
{
title: "Public transport - Routes",
description: "here is what we've done with the routes",
views: [ { center: centers.gtHQ, zoom: 11, span: 12 } ],
layers: [
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:PTV.PTV_BUS_ROUTE_METRO", sld: sldPrefix + "sii-PTV.PTV_BUS_ROUTE_METRO.sld" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_BUS_ROUTE_SCHOOL", sld: sldPrefix + "sii-PTV.PTV_BUS_ROUTE_SCHOOL.sld"} },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAM_ROUTE", sld: sldPrefix + "sii-PTV.PTV_TRAM_ROUTE.sld" } },
{ server: servers.depi, options: { layers: "sii:PTV.PTV_TRAIN_CORRIDOR_CENTRELINE", sld: sldPrefix + "sii-PTV.PTV_TRAIN_CORRIDOR_CENTRELINE.sld" } } ]
]
},
{
title: "Public transport - Streets",
views: [
{ center: centers.gtHQ, zoom: 13, span: 4, attribution: "Before"},
{ center: centers.gtHQ, zoom: 13, span: 8 }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMLITE.VMLITE_TR_ROAD" } } ],
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:VMLITE.VMLITE_TR_ROAD", sld: sldPrefix + "sii-VMLITE.VMLITE_TR_ROAD.sld"} } ,
{ server: servers.depi, options: { layers: "sii:VMLITE.VMLITE_TR_ROAD", sld: sldPrefix + "sii-VMLITE.VMLITE_TR_ROAD-labels.sld"} }
]
]
},
{
description: "here we use a different layer for a closer zoom view",
views: [ { center: centers.gtHQ, zoom: 16, span: 12 } ],
layers: [
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:VMTRANS.TR_ROAD", sld: sldPrefix + "sii-VMTRANS.TR_ROAD.sld", tiled: true } } ,
{ server: servers.depi, options: { layers: "sii:VMTRANS.TR_ROAD", sld: sldPrefix + "sii-VMTRANS.TR_ROAD-labels.sld" } }
]
]
},
{
title: "Water Layers",
views: [
{ center: centers.clc, zoom: 13, span: 6, attribution: "Default" },
{ center: centers.clc, zoom: 13, span: 6 }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMHYDRO.HY_WATER_AREA_POLYGON" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMHYDRO.HY_WATER_AREA_POLYGON", sld: sldPrefix + "sii-VMHYDRO.HY_WATER_AREA_POLYGON.sld" } } ]
]
},
{
title: "Sea Level Rise",
description: "",
views: [
{ center: centers.bay, zoom: 13, span: 4, attribution: "2009+2100, 82cm rise" },
{ center: centers.bay, zoom: 13, span: 4, attribution: "2009-2070" },
{ center: centers.bay, zoom: 13, span: 4, attribution: "2009-2070 plus increasing storms" }
],
layers: [
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:COASTS.SLR82CM_2100", sld: sldPrefix + "sii-COASTS.SLR82CM_2100.sld" } },
{ server: servers.depi, options: { layers: "sii:COASTS.SLR00CM_2009", sld: sldPrefix + "sii-COASTS.SLR00CM_2009.sld" } }
],
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:COASTS.SLR82CM_2100", sld: sldPrefix + "sii-COASTS.SLR82CM_2100.sld" } },
{ server: servers.depi, options: { layers: "sii:COASTS.SLR00CM_2009", sld: sldPrefix + "sii-COASTS.SLR00CM_2009.sld" } }
],
[layers.basemap,
{ server: servers.depi, options: { layers: "sii:COASTS.SLR47CM_ST_2070", sld: sldPrefix + "sii-COASTS.SLR47CM_ST_2070.sld" } },
{ server: servers.depi, options: { layers: "sii:COASTS.SLR00CM_2009", sld: sldPrefix + "sii-COASTS.SLR00CM_2009.sld" } }
]
]
},
{
title: "Admin Layers",
description: "A different version of how to show locality poligons, when zooming the style is changing, too.",
views: [
{ center: centers.gtHQ, zoom: 12, span: 6, attribution: "Default" },
{ center: centers.gtHQ, zoom: 12, span: 6 }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMADMIN.LOCALITY_POLYGON" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMADMIN.LOCALITY_POLYGON", sld: sldPrefix + "sii-VMADMIN.LOCALITY_POLYGON.sld" } } ]
]
},
{
views: [ { center: centers.gtHQ, zoom: 7, span: 12, attribution: "Catchment Management Authority Boundaries" } ],
layers: [ [layers.basemap, { server: servers.depi, options: { layers: "sii:CATCHMENTS.CMA100", sld: sldPrefix + "sii-CATCHMENTS.CMA100.sld" } } ] ]
},
{
views: [
{ center: centers.bay, zoom: 10, span: 4, attribution: "LGA" },
{ center: centers.bay, zoom: 10, span: 4, attribution: "Parish" },
{ center: centers.bay, zoom: 10, span: 4, attribution: "State Assembly" }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMADMIN.LGA_POLYGON", sld: sldPrefix + "sii-VMADMIN.LGA_POLYGON.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMADMIN.PARISH_POLYGON", sld: sldPrefix + "sii-VMADMIN.PARISH_POLYGON.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMADMIN.STATE_ASSEMBLY_2001", sld: sldPrefix + "sii-VMADMIN.STATE_ASSEMBLY_2001.sld" } } ]
]
},
{
description: " It is also easy to recreat default sld styles in a shorter and more compact way using css.",
views: [
{ center: centers.gtHQ, zoom: 8, span: 6, attribution: "Default" },
{ center: centers.gtHQ, zoom: 8, span: 6 }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:FLORAFAUNA1.VBIOREG100" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:FLORAFAUNA1.VBIOREG100", sld: sldPrefix + "sii-FLORAFAUNA1.VBIOREG100.sld" } } ]
]
},
{
title: "Vegetation Layers",
views: [
{ center: centers.gtHQ, zoom: 12, span: 6, attribution: "Default" },
{ center: centers.gtHQ, zoom: 12, span: 6, attribution: "Tree density" }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMVEG.TREE_DENSITY" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMVEG.TREE_DENSITY", sld: sldPrefix + "sii-VMVEG.TREE_DENSITY.sld" } } ]
]
},
{
description: "Style is changing in different zoom levels, here showing wetlands. When showing big areas, the polygon is filled by colour, when zooming in, the area is filled by strokes with the distance between the strokes chaning to bigger distances when zooming in and at the closest, border strokes appear.",
views: [
{ center: centers.pIsl, zoom: 8, span: 4, attribution: "Zoom 8" },
{ center: centers.pIsl, zoom: 10, span: 4, attribution: "Zoom 10" },
{ center: centers.pIsl, zoom: 18, span: 4, attribution: "Zoom 18" }
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:FLORAFAUNA1.WETLANDDIR", sld: sldPrefix + "sii-FLORAFAUNA1.WETLANDDIR.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:FLORAFAUNA1.WETLANDDIR", sld: sldPrefix + "sii-FLORAFAUNA1.WETLANDDIR.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:FLORAFAUNA1.WETLANDDIR", sld: sldPrefix + "sii-FLORAFAUNA1.WETLANDDIR.sld" } } ]
]
},
{
title: "Topographical Layers",
views: [
{ center: centers.gtHQ, zoom: 11, span: 8, attribution: "zoom 11 shows only points"},
{ center: centers.clc, zoom: 14, span: 4, attribution: "zoom 14 shows points with description"}
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMELEV.EL_GRND_SURFACE_POINT", sld: sldPrefix + "sii-VMELEV.EL_GRND_SURFACE_POINT.sld" } } ],
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMELEV.EL_GRND_SURFACE_POINT", sld: sldPrefix + "sii-VMELEV.EL_GRND_SURFACE_POINT.sld" } } ]
]
},
{
views: [
{ center: centers.gtHQ, zoom: 9, span: 6, attribution: "this shows the area around Melbourne"},
{ center: centers.gtHQ, zoom: 8, span: 6, attribution: "this layer shows Victoria"}
],
layers: [
[layers.basemap, { server: servers.depi, options: { layers: "sii:VMELEV.EL_CONTOUR_1TO5M", sld: sldPrefix + "sii-VMELEV.EL_CONTOUR_1TO5M.sld" } } ],
layers.contour = [layers.basemap, { server: servers.depi, options: { layers: "sii:VMELEV.EL_CONTOUR", sld: sldPrefix + "sii-VMELEV.EL_CONTOUR.sld" } } ]
]
},
{
views: [
{ center: centers.haGa, zoom: 11, span: 4, attribution: "Zoom 11" },
{ center: centers.haGa, zoom: 13, span: 4, attribution: "Zoom 13" },
{ center: centers.haGa, zoom: 15, span: 4, attribution: "Zoom 15" }
],
layers: [
layers.contour,
layers.contour,
layers.contour
]
}
];
var egTemplate = ' \
<div class="row example"> \
<div class="span12"> \
<h2>{{title}}</h2> \
{{#description}} \
<p>{{description}}</p> \
{{/description}} \
<div class="row"> \
{{#views}} \
<div id="eg{{egIndex}}view{{viewIndex}}" class="span{{span}} map"></div> \
{{/views}} \
</div> \
</div> \
</div> \
';
var defaultLayerOptions = {
format: 'image/png',
transparent: true
};
_(examples).each(function(eg, egIndex) {
var viewData = {
title: eg.title,
description: eg.description,
views: _(eg.views).map(function(view, viewIndex) {
return $.extend({}, view, { egIndex: egIndex, viewIndex: viewIndex });
})
};
$(".examples").append(Mustache.render(egTemplate, viewData));
_(_.range(eg.views.length)).each(function(viewIndex) {
var view = eg.views[viewIndex];
var layers = eg.layers[viewIndex];
var map = L.map(["eg", egIndex, "view", viewIndex].join('')).setView(view.center, view.zoom);
map.attributionControl.setPrefix("");
// map.attributionControl.setPosition("bottomleft");
map.attributionControl.addAttribution(view.attribution);
_(layers).each(function(config) {
var layerClass = config.options.tiled ? L.TileLayer : L.SingleTileWMSLayer;
var layer = new layerClass(config.server.url, $.extend({},
defaultLayerOptions,
config.server.options,
config.options
));
layer.addTo(map);
});
});
});