Jonas Kress (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/384492 )
Change subject: Add app example ...................................................................... Add app example Simple app that shows items nearby. Change-Id: I4085f1c1fe5e93909e10f0b7f9c191fb75777df7 --- A examples/app/what_sourrounds_me.html 1 file changed, 91 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui refs/changes/92/384492/1 diff --git a/examples/app/what_sourrounds_me.html b/examples/app/what_sourrounds_me.html new file mode 100644 index 0000000..d3c4e30 --- /dev/null +++ b/examples/app/what_sourrounds_me.html @@ -0,0 +1,91 @@ +<!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 ?category ?categoryLabel ?place ?placeLabel ?image ?website ?dist ?location (?categoryLabel as ?layer) WHERE { \n' + + ' SERVICE wikibase:around { \n' + + ' ?place wdt:P625 ?location. \n' + + ' bd:serviceParam wikibase:center "Point(' + longitude + ' ' + latitude + ')"^^geo:wktLiteral. \n' + + ' bd:serviceParam wikibase:radius "1". \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 ?categoryLabel. \n' + + ' } \n' + + ' BIND(geof:distance("Point(' + longitude + ' ' + latitude + ')"^^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> -- To view, visit https://gerrit.wikimedia.org/r/384492 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4085f1c1fe5e93909e10f0b7f9c191fb75777df7 Gerrit-PatchSet: 1 Gerrit-Project: wikidata/query/gui Gerrit-Branch: master Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits