I request Wikidata entities and get their geoshape property (P3896).
For example (try it):
SELECT ?item ?itemLabel ?geoshape ?geoshapeLabel
WHERE
{
VALUES ?item { wd:Q142 }
?item wdt:P3896 ?geoshape.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
So I get an url: http://commons.wikimedia.org/data/main/Data:France.map
I tried to fetch data with Javascript:
fetch('http://commons.wikimedia.org/data/main/Data:France.map?origin=*')
fetch('https://commons.wikimedia.org/w/index.php?title=Data:France.map&action=raw&origin=*')
But I got error due to CORS policy:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Is there any way to get geojson data from Wikidata from web application?
According to @Pascalo we can use
The complete JS solution to get geojson data from Wikidata can be the following: