<div id="app">
<l-map :bounds="bounds" style="position: absolute; top: 0;right: 0; bottom: 0; left: 0;">
<l-tile-layer :url="tileurl"></l-tile-layer>
<l-marker v-for="item in items" :lat-lng="{lat: item.lat.value, lon: item.long.value }">
<l-popup>
<a :href="item.uri.value" target="_blank" rel="noreferrer noopener">
{{ item.label.value }}
</a>
</l-popup>
</l-marker>
</l-map>
</div>
Vue.component("l-map", window.Vue2Leaflet.LMap);
Vue.component("l-tile-layer", window.Vue2Leaflet.LTileLayer);
Vue.component("l-marker", window.Vue2Leaflet.LMarker);
Vue.component("l-popup", window.Vue2Leaflet.LPopup);
new Vue({
el: "#app",
data() {
return {
items: [],
tileurl: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
bounds: null
};
},
mounted() {
var self = this;
axios
.get("https://jpsearch.go.jp/rdf/sparql/", {
params: {
query: `
SELECT DISTINCT ?uri ?label ?category ?date ?pref ?lat ?long WHERE {
?uri rdfs:label ?label ;
rdf:type type:建築 ;
schema:spatial place:京都 ;
jps:spatial/jps:value/rdfs:label ?pref ;
schema:temporal/rdfs:label ?date ;
schema:category/rdfs:label ?category ;
jps:spatial/schema:geo/schema:latitude ?lat;
jps:spatial/schema:geo/schema:longitude ?long;
jps:spatial/schema:geo/jps:within+ <http://geohash.org/xn0x1> .
}
limit 1000`,
output: "json"
}
})
.then(function (response) {
self.items = response.data.results.bindings;
self.items.forEach(function (item) {
self.setBounds(item.lat.value, item.long.value);
});
})
.catch(function (error) {
console.log(error);
});
},
methods: {
setBounds: function (lat, long) {
if (!this.bounds)
this.bounds = [
[lat, long],
[lat, long]
];
if (this.bounds[1][0] > lat) this.bounds[1][0] = lat;
if (this.bounds[0][0] < lat) this.bounds[0][0] = lat;
if (this.bounds[1][1] > long) this.bounds[1][1] = long;
if (this.bounds[0][1] < long) this.bounds[0][1] = long;
}
}
});