-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhat_sourrounds_me.html
92 lines (81 loc) · 3.87 KB
/
what_sourrounds_me.html
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Wikidata Query - Result Views</title>
<!-- build:css css/style.min.css -->
<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="../../node_modules/ekko-lightbox/dist/ekko-lightbox.css">
<link rel="stylesheet" href="../../node_modules/bootstrap-table/dist/bootstrap-table.css">
<link rel="stylesheet" href="../../node_modules/leaflet/dist/leaflet.css">
<link rel="stylesheet" href="../../node_modules/leaflet-fullscreen/dist/leaflet.fullscreen.css">
<link rel="stylesheet" href="../../node_modules/leaflet-zoombox/L.Control.ZoomBox.css">
<link rel="stylesheet" href="../../style.css">
<!-- endbuild -->
<link rel="shortcut icon" href="//www.wikidata.org/static/favicon/testwikidata.ico">
<!-- build:js js/shim.min.js -->
<script src="../../node_modules/es6-shim/es6-shim.js"></script>
<!-- endbuild -->
</head>
<body>
<!-- JS vendor files -->
<script src="../../node_modules/jquery/dist/jquery.js"></script>
<script src="../../node_modules/underscore/underscore.js"></script>
<script src="../../node_modules/ekko-lightbox/dist/ekko-lightbox.js"></script>
<script src="../../node_modules/leaflet/dist/leaflet.js"></script>
<script src="../../node_modules/leaflet-fullscreen/dist/Leaflet.fullscreen.js"></script>
<script src="../../node_modules/leaflet-zoombox/L.Control.ZoomBox.js"></script>
<script src="../../node_modules/moment/min/moment-with-locales.js"></script>
<script src="../../node_modules/wellknown/wellknown.js"></script>
<script src="../../node_modules/d3/d3.js"></script>
<!-- JS files -->
<script src="../../wikibase/queryService/api/Sparql.js"></script>
<script src="../../wikibase/queryService/RdfNamespaces.js"></script>
<script src="../../wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js"></script>
<script src="../../wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js"></script>
<script src="../../wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js"></script>
<div id="result"></div>
<script type="text/javascript">
/* SPARQL Query */
function getQuery( latitude, longitude ) {
return ' PREFIX geo: <http://www.opengis.net/ont/geosparql#> \n' +
' PREFIX geof: <http://www.opengis.net/def/geosparql/function/> \n' +
' \n' +
' #defaultView:Map \n' +
' SELECT * WHERE { \n' +
' SERVICE wikibase:around { \n' +
' ?place wdt:P625 ?location. \n' +
' bd:serviceParam wikibase:center "Point(' + latitude + ' ' + longitude + ')"^^geo:wktLiteral. \n' +
' bd:serviceParam wikibase:radius "300". \n' +
' } \n' +
' ?place wdt:P31 ?category. \n' +
' OPTIONAL { \n' +
' ?place wdt:P18 ?image. \n' +
' ?place wdt:P856 ?website. \n' +
' } \n' +
' SERVICE wikibase:label { \n' +
' bd:serviceParam wikibase:language "en". \n' +
' ?place rdfs:label ?placeLabel. \n' +
' bd:serviceParam wikibase:language "en". \n' +
' ?category rdfs:label ?layer. \n' +
' } \n' +
' BIND(geof:distance("Point(' + latitude + ' ' + longitude + ')"^^geo:wktLiteral, ?location) AS ?dist) \n' +
' } ' ;
}
/* JS Code */
$(document).ready(function() {
navigator.geolocation.getCurrentPosition(function(position) {
query = getQuery( position.coords.latitude, position.coords.longitude )
var api = new wikibase.queryService.api.Sparql();
api.query( query ).done( function () {
var result = new wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser()
result.setResult( api.getResultRawData() );
result.draw( $( '#result' ) );
} );
});
} );
</script>
</body>
</html>