You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,17 +4,17 @@
4
4
5
5
A library of [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for tasks related to addresses and planning permission in the UK built with [Lit](https://lit.dev/), [Vite](https://vitejs.dev/), and [Ordnance Survey APIs](https://developer.ordnancesurvey.co.uk/).
6
6
7
-
***Web map***
7
+
**_Web map_**
8
8
9
9
`<my-map />` is an [OpenLayers](https://openlayers.org/)-powered map to support drawing and modifying red-line boundaries. Other supported modes include: highlighting an OS Feature that intersects with a given address point; clicking to select and merge multiple OS Features into a single boundary; and displaying static point or polygon data. Events are dispatched with the calculated area and geojson representation when you change your drawing.
`<postcode-search />` is a [GOV.UK-styled](https://frontend.design-system.service.gov.uk/) input that validates UK postcodes using these [utility methods](https://www.npmjs.com/package/postcode). When a postcode is validated, an event is dispatched containing the sanitized string.
16
16
17
-
***Address autocomplete***
17
+
**_Address autocomplete_**
18
18
19
19
`<address-autocomplete />` fetches addresses in a given UK postcode using the [OS Places API](https://developer.ordnancesurvey.co.uk/os-places-api) and displays them using GOV.UK's [accessible-autocomplete](https://github.com/alphagov/accessible-autocomplete) component. An event is dispatched with the OS record when you select an address.
20
20
@@ -31,23 +31,25 @@ Find these components in the wild, including what we're learning through public
31
31
32
32
## Bring your own API keys
33
33
34
-
Different features rely on different APIs - namely from Ordnance Survey and Mapbox.
34
+
Different features rely on different APIs - namely from Ordnance Survey and Mapbox.
35
35
36
-
You can set keys directly as props (eg `osApiKey`) on the applicable web components or [use a proxy](https://github.com/theopensystemslab/map/blob/main/docs/how-to-use-a-proxy.md) to mask these secrets.
36
+
You can set keys directly as props (eg `osApiKey`) on the applicable web components or [use a proxy](https://github.com/theopensystemslab/map/blob/main/docs/how-to-use-a-proxy.md) to mask these secrets.
37
37
38
38
Address autocomplete utilises the OS Places API.
39
39
40
40
For the map:
41
+
41
42
- The `basemap` prop defaults to `"OSVectorTile"` which requires the OS Vector Tiles API
42
43
- Basemap `"OSRaster"` uses the OS Maps API
43
44
- Basemap `"MapboxSatellite"` requires a Mapbox Access Token with with scope `style:read`
44
45
- The `"OSM"` (OpenStreetMap) basemap is available for users without any keys, and as a fallback if any of the above basemaps fail to build
45
46
-`clickFeatures` requires the OS Features API
46
47
47
48
When using Ordnance Survey APIs:
49
+
48
50
- Update the `osCopyright` attribution prop with your license number
49
51
- Configure an optional `osProxyEndpoint` to avoid exposing your keys (set this instead of `osApiKey`)
50
-
-** We are not currently supporting a similar proxy for Mapbox because access tokens can be restricted to specific URLs via your account
52
+
-\*\* We are not currently supporting a similar proxy for Mapbox because access tokens can be restricted to specific URLs via your account
51
53
52
54
## Running locally
53
55
@@ -75,6 +77,7 @@ We use [Pitsby](https://pitsby.com/) for documenting our web components. It's si
75
77
We publish this package via [NPM](https://www.npmjs.com/package/@opensystemslab/map).
76
78
77
79
To create a new release:
80
+
78
81
1. Open a new PR against `main` which bumps the package.json "version" & creates a CHANGELOG.md entry, request code review & merge on approval
79
82
1. Run `npm publish` or `npm publish --tag next` if making a pre-release (requires permissions to OSL team in NPM & access to 2-factor auth method)
80
83
1.[Draft a new release](https://github.com/theopensystemslab/map/releases) via GitHub web: tag should match version, automatically generate changenotes and link above PR, then "Publish" and set as latest version (or set as pre-release if you used `--tag next` in above command)
Copy file name to clipboardExpand all lines: docs/how-to-use-a-proxy.md
+15-8Lines changed: 15 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,20 @@
1
1
# How to: Use a MyMap & AddressAutocomplete with a proxy
2
2
3
3
## Context
4
-
Both `MyMap` and `AddressAutocomplete` can call the Ordnance Survey API directly, or via a proxy.
4
+
5
+
Both `MyMap` and `AddressAutocomplete` can call the Ordnance Survey API directly, or via a proxy.
5
6
6
7
Calling the API directly may be suitable for internal use, where exposure of API keys is not a concern, whilst calling a proxy may be more suitable for public use.
7
8
8
9
A proxy endpoint can be supplied via the `osProxyEndpoint` property on these components.
9
10
10
-
Proxies are required to complete the following actions in order to work successfully -
11
+
Proxies are required to complete the following actions in order to work successfully -
11
12
12
13
- Append a valid OS API key as a search parameter to incoming requests
13
14
- Modify outgoing response with suitable CORS / CORP headers to allow the originating site access to the returned assets
14
15
15
16
## Diagram
17
+
16
18
```mermaid
17
19
sequenceDiagram
18
20
autonumber
@@ -28,25 +30,29 @@ sequenceDiagram
28
30
```
29
31
30
32
## Examples
31
-
Please see the sample code below for how a proxy could be implemented -
33
+
34
+
Please see the sample code below for how a proxy could be implemented -
32
35
33
36
### Express
37
+
34
38
Below is an annotated example of a simple proxy using [Express](https://github.com/expressjs/express) & [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
> A working and more fleshed out example (in TypeScript) can be seen [here in the PlanX API](https://github.com/theopensystemslab/planx-new/blob/production/api.planx.uk/proxy/ordnanceSurvey.ts).
103
+
104
+
> A working and more fleshed out example (in TypeScript) can be seen [here in the PlanX API](https://github.com/theopensystemslab/planx-new/blob/production/api.planx.uk/proxy/ordnanceSurvey.ts).
0 commit comments