Skip to content

Commit 8b3fe32

Browse files
authored
Merge pull request #10 from hatnote/dev
version 0.9
2 parents 93feca7 + f3b0c0d commit 8b3fe32

5 files changed

Lines changed: 84 additions & 33 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "monumental",
3-
"version": "0.8.0",
3+
"version": "0.9.0",
44
"private": true,
55
"description": "Monumental app",
66
"main": "src/index.js",

src/components/main/map/map.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
Dashboard
55
</md-button>
66
<span flex></span>
7+
<md-autocomplete
8+
md-input-name="autocompleteField"
9+
md-selected-item="$ctrl.search.selectedItem"
10+
md-search-text="$ctrl.search.text"
11+
md-items="item in $ctrl.querySearch($ctrl.search.text)"
12+
md-selected-item-change="$ctrl.goToItem(item)"
13+
md-item-text="item.label"
14+
md-min-length="1"
15+
placeholder="Search"
16+
md-menu-class="autocomplete-custom-template">
17+
<md-item-template>
18+
<strong>{{item.label}}</strong>
19+
<span>{{item.description}}</span>
20+
</md-item-template>
21+
</md-autocomplete>
722
</div>
823
</md-toolbar>
924
<div class="container" layout="column" layout-align="space-between stretch" flex>

src/components/main/map/map.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import _ from 'lodash';
2-
31
import './map.scss';
42
import template from './map.html';
53

@@ -11,25 +9,34 @@ function controller($location, $scope, $state, $stateParams, $timeout, leafletDa
119

1210
// bindings
1311

14-
vm.goToItem = item => $state.go('main.list', { id: item.id.substring(1) });
12+
vm.goToItem = item => setMap(item);
1513
vm.map = mapService.getMapInstance({ center: { lat: 51.686, lng: 19.545, zoom: 7 } });
14+
vm.querySearch = text => wikidata.getSearch(text);
1615
vm.list = [];
1716
vm.listParams = {};
1817
vm.loading = vm.loadingMap = true;
1918
vm.search = {};
2019

2120
// activate
2221

22+
let langs = $stateParams.lang ? [$stateParams.lang] : [];
23+
langs = langs.concat(localStorageService.get('languages') || ['en', 'de']);
24+
wikidata.setLanguages(langs);
25+
2326
$scope.$on('centerUrlHash', (event, centerHash) => {
2427
$location.search({ c: centerHash });
2528
});
2629

2730
$timeout(() => {
2831
vm.loadingMap = false;
2932
leafletData.getMap().then((map) => {
30-
getDataBB(map.getBounds());
31-
map.on('dragend zoomend', () => {
33+
if (map.getZoom() > 12) {
3234
getDataBB(map.getBounds());
35+
}
36+
map.on('dragend zoomend', () => {
37+
if (map.getZoom() > 12) {
38+
getDataBB(map.getBounds());
39+
}
3340
});
3441
});
3542
}, 100);
@@ -38,15 +45,16 @@ function controller($location, $scope, $state, $stateParams, $timeout, leafletDa
3845

3946
function getDataBB(bounds) {
4047
vm.loading = true;
41-
wikidata.getSPARQL(`SELECT ?item ?itemLabel ?admin ?adminLabel ?image ?coord WHERE {
48+
wikidata.getSPARQL(`SELECT ?item ?itemLabel ?admin ?adminLabel ?image ?coord ?heritage WHERE {
4249
SERVICE wikibase:box {
4350
?item wdt:P625 ?coord .
4451
bd:serviceParam wikibase:cornerWest "Point(${bounds.getSouthWest().lng} ${bounds.getSouthWest().lat})"^^geo:wktLiteral .
4552
bd:serviceParam wikibase:cornerEast "Point(${bounds.getNorthEast().lng} ${bounds.getNorthEast().lat})"^^geo:wktLiteral .
4653
}
4754
OPTIONAL { ?item wdt:P131 ?admin . }
4855
OPTIONAL { ?item wdt:P18 ?image . }
49-
SERVICE wikibase:label { bd:serviceParam wikibase:language "pl" }
56+
?item wdt:P1435 ?heritage .
57+
SERVICE wikibase:label { bd:serviceParam wikibase:language "${langs.join(',')}" }
5058
}`).then((data) => {
5159
vm.map.markers = {};
5260
vm.list = data.map(element => setListElement(element));
@@ -96,6 +104,24 @@ function controller($location, $scope, $state, $stateParams, $timeout, leafletDa
96104
return obj;
97105
}
98106

107+
function setMap(item) {
108+
if (!item || !item.id) { return; }
109+
vm.loading = true;
110+
wikidata.getById(item.id)
111+
.then((data) => {
112+
const element = Object.values(data)[0];
113+
const coords = element.claims.P625;
114+
if (coords) {
115+
const lat = coords.values[0].value.latitude;
116+
const lng = coords.values[0].value.longitude;
117+
leafletData.getMap().then((map) => {
118+
map.setView([lat, lng], 14);
119+
getDataBB(map.getBounds());
120+
});
121+
}
122+
});
123+
}
124+
99125
function setMarker(element) {
100126
return {
101127
lat: +element.coord[1],

src/services/map.service.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const MapService = () => {
4747
name: 'Monuments',
4848
type: 'markercluster',
4949
visible: true,
50+
layerOptions: {
51+
spiderfyOnMaxZoom: false,
52+
showCoverageOnHover: false,
53+
zoomToBoundsOnClick: true,
54+
disableClusteringAtZoom: 17,
55+
},
5056
},
5157
},
5258
},

src/styles/_general.scss

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,79 @@
11
@import 'variables';
22

33
html, body {
4-
width: 100%;
5-
height: 100%;
4+
width: 100%;
5+
height: 100%;
66
}
77

88
body {
9-
color: $darkGrey;
10-
font: 16px Roboto, Arial, sans-serif;
9+
color: $darkGrey;
10+
font: 16px Roboto, Arial, sans-serif;
1111
}
1212

1313
::-webkit-scrollbar {
14-
width: 5px;
15-
background: transparent;
14+
width: 5px;
15+
background: transparent;
1616
}
1717
::-webkit-scrollbar-thumb {
18-
background: rgba(0,0,0,0.2);
18+
background: rgba(0,0,0,0.2);
1919
}
2020

2121
md-content {
22-
margin: 20px;
22+
margin: 20px;
2323
}
2424

2525
.container {
26-
min-height: calc(100vh - 64px);
26+
min-height: calc(100vh - 64px);
2727

28-
ui-view, ui-view > * {
29-
width: 100%;
30-
}
28+
ui-view, ui-view > * {
29+
width: 100%;
30+
}
3131
}
3232

3333
////
3434

3535
.link {
36-
cursor: pointer;
36+
cursor: pointer;
3737
}
3838

3939
a, a.link {
40-
cursor: pointer;
41-
color: #8f0000;
42-
text-decoration: none;
40+
cursor: pointer;
41+
color: #8f0000;
42+
text-decoration: none;
4343
}
4444

4545
.muted {
46-
color: $lightGrey;
46+
color: $lightGrey;
4747
}
4848

4949
.full-width {
50-
width: 100%;
50+
width: 100%;
5151
}
5252

5353
.text-left {
54-
text-align: left;
54+
text-align: left;
5555
}
5656

5757
.text-right {
58-
text-align: right;
58+
text-align: right;
5959
}
6060

6161
.invisible {
62-
width: 0;
63-
height: 0;
64-
opacity: 0;
62+
width: 0;
63+
height: 0;
64+
opacity: 0;
6565
}
6666

6767
strong {
68-
font-weight: 500;
68+
font-weight: 500;
6969
}
7070

7171
////
7272

7373
.toolbar {
74-
padding: 0 5px;
74+
padding: 0 5px;
75+
}
76+
77+
.md-virtual-repeat-container.md-autocomplete-suggestions-container {
78+
z-index: 1000 !important;
7579
}

0 commit comments

Comments
 (0)