[英]How to get coordinates of a place using google map javascript api
[英]Get coordinates of a place using Wikidata
我正在使用 Wikidata API 從名人那里獲取出生位置,然后使用 Google Maps API 顯示該位置。 這是我使用的維基數據請求:
SELECT DISTINCT ?item ?itemLabel ?birthLocation ?birthLocationLabel WHERE {
?item (wdt:P31|wdt:P101|wdt:P106)/wdt:P279* wd:Q482980 ;
rdfs:label "Mary Wollstonecraft"@en ;
wdt:P19 ?birthLocation
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
然后我使用谷歌地理編碼器從birthLocationLabel 獲取經緯度,並將其顯示在地圖上,但是有時地理編碼器找不到位置(也許這個地方不再存在),所以我想想知道是否可以從 wikidata 查詢中獲取坐標? 我知道出生地點有一個“坐標位置”屬性,但我不知道如何訪問它。
這是維基數據查詢的鏈接
這對我?birthLocation wdt:P625 ?coordinates
所以整個查詢將是:
SELECT DISTINCT ?item ?itemLabel ?coordinates ?birthLocation ?birthLocationLabel
WHERE {
?item ((wdt:P31|wdt:P101|wdt:P106)/(wdt:P279*)) wd:Q482980;
rdfs:label "Mary Wollstonecraft"@en;
wdt:P19 ?birthLocation.
?birthLocation wdt:P625 ?coordinates.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
這將返回:
[{
"item": "http://www.wikidata.org/entity/Q101638",
"itemLabel": "Mary Wollstonecraft",
"coordinates": "Point(-0.075 51.5166)",
"birthLocation": "http://www.wikidata.org/entity/Q123219",
"birthLocationLabel": "Spitalfields"
}]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.