Published
Edited
Mar 19, 2021
Insert cell
Insert cell
viewof apiKey = text({
title: "your os api key",
placeholder: "paste here",
description: "this can be obtained from http://os.uk/developers"
})
Insert cell
longitude = 0
Insert cell
latitude = 51.49
Insert cell
radius = 100
Insert cell
Insert cell
axios
.get(
`https://api.os.uk/search/names/v1/nearest?point=${bngCoord}&key=${apiKey}&radius=${radius}`
)
.then(function(err, response) {
return JSON.stringify(
response.data.results[0]['GAZETTEER_ENTRY']['NAME1'],
null,
2
);
})
.catch(err => {
return md`have you added your \`apiKey\`?`;
})
Insert cell
Insert cell
md`# functions`
Insert cell
bngCoord = proj4('EPSG:27700', [longitude, latitude]).map(function(key) {
return Number(key.toFixed(2));
})
Insert cell
md`# libs`
Insert cell
axios = require('axios@0.21.1/dist/axios.min.js').catch(() => window["axios"])
Insert cell
proj4 = require('proj4@2.7.2/dist/proj4-src.js').catch(() => window["proj4"])
Insert cell
import { text } from "@jashkenas/inputs"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more