Repository navigation
Expand file tree
/
Copy pathfront.js
More file actions
47 lines (47 loc) · 1.63 KB
/
Copy pathfront.js
File metadata and controls
47 lines (47 loc) · 1.63 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
L.K.Map.addInitHook(function () {
this.whenReady(function () {
var container = L.DomUtil.create('div', 'map-places-container'),
title = L.DomUtil.create('h3', '', container),
list = L.DomUtil.create('div', '', container),
self = this;
title.innerHTML = 'Places';
var renderPlaces = function () {
list.innerHTML = '';
var places = L.K.Config.project.places || [];
for (var i = 0; i < places.length; i++) {
renderPlace(places[i]);
}
};
this.sidebar.addTab({
label: 'Places',
className: 'places',
content: container,
callback: renderPlaces
});
var renderPlace = function (place) {
var el = L.DomUtil.create('div', 'one-place', list),
name = L.DomUtil.create('h4', '', el), comment;
name.textContent = place.place_name;
if (place.comment) {
comment = L.DomUtil.create('div', '', el);
comment.textContent = place.comment;
}
L.DomEvent.on(el, 'click', function () {
self.setView(place.center, place.zoom || self.getZoom());
});
};
this.sidebar.rebuild();
var commandCallback = function () {
this.sidebar.open('.places');
renderPlaces();
};
this.commands.add({
keyCode: L.K.Keys.D,
ctrlKey: true,
altKey: true,
callback: commandCallback,
context: this,
name: 'Places: show'
});
});
});