@vexpay/maps 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chu Ventures
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,145 @@
1
- # Temporary Holding Version
1
+ # VEX Maps for JavaScript
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Address search, reverse lookup, maps and a location picker for **Venezuela** and **Colombia**, built on open data (OpenStreetMap, Overture Maps, GeoNames and Colombian official data). No Google Maps, no Mapbox.
4
+
5
+ - **Client:** `search`, `reverse` and `countries`, typed, for the browser and Node.
6
+ - **Ready-made pieces:** a map, an address field with suggestions, and a location picker (search, then move the map so the pin sits on the door).
7
+ - **React:** the same pieces as components, from `@vexpay/maps/react`.
8
+ - **Formats:** ESM, CommonJS and a `<script>` build (`window.VexMaps`). MapLibre and React are optional peers.
9
+ - **Licence:** MIT.
10
+
11
+ You need a VEX Maps key. Keys are made in the VEX Maps dashboard by the Chu Ventures team.
12
+
13
+ ## Keys
14
+
15
+ | Key | Prefix | Where | Can call |
16
+ |---|---|---|---|
17
+ | Publishable | `vexmap_pk_…` | the browser, from your allowed origins only | `search`, `reverse` |
18
+ | Secret | `vexmap_sk_…` | your server only | everything, including `countries` |
19
+
20
+ The SDK refuses a secret key in a browser.
21
+
22
+ ## Install
23
+
24
+ ```sh
25
+ npm install @vexpay/maps maplibre-gl
26
+ ```
27
+
28
+ `maplibre-gl` is needed only for the map and the picker. Load its CSS once:
29
+
30
+ ```js
31
+ import 'maplibre-gl/dist/maplibre-gl.css';
32
+ ```
33
+
34
+ ## React, in five minutes
35
+
36
+ ```tsx
37
+ import { useVexMaps, LocationPicker } from '@vexpay/maps/react';
38
+ import 'maplibre-gl/dist/maplibre-gl.css';
39
+
40
+ export function DeliveryStep({ onPicked, onFallback }) {
41
+ const vexmaps = useVexMaps({ key: process.env.NEXT_PUBLIC_VEX_MAPS_KEY!, country: 've' });
42
+ return (
43
+ <LocationPicker
44
+ client={vexmaps}
45
+ style={{ height: 420 }}
46
+ onConfirm={({ point, reverse, picked }) => onPicked({ point, zone: reverse?.zone, street: reverse?.street?.label })}
47
+ onUnavailable={() => onFallback()} // VEX Maps down or slow: show your typed address fields
48
+ />
49
+ );
50
+ }
51
+ ```
52
+
53
+ Also available: `<VexMap>` (a map, `onReady` gives the MapLibre map) and `<AddressSearch>` (the field alone, `onSelect` gives the result). Each takes `onUnavailable`.
54
+
55
+ ## Plain HTML, in five minutes
56
+
57
+ ```html
58
+ <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.css" />
59
+ <script src="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.js"></script>
60
+ <script src="https://unpkg.com/@vexpay/maps@0.1/dist/vexmaps.global.js"></script>
61
+
62
+ <div id="picker" style="height: 420px"></div>
63
+ <script>
64
+ const vexmaps = VexMaps.createVexMaps({ key: 'vexmap_pk_…', country: 've' });
65
+ const picker = VexMaps.mountLocationPicker(document.getElementById('picker'), { client: vexmaps });
66
+ picker.on('confirm', ({ point, reverse }) => console.log(point, reverse && reverse.zone));
67
+ picker.on('unavailable', () => { /* show typed address fields */ });
68
+ </script>
69
+ ```
70
+
71
+ The `<script>` build does not include MapLibre: load it first, as above.
72
+
73
+ ## Node, in five minutes
74
+
75
+ ```js
76
+ import { createVexMaps } from '@vexpay/maps';
77
+
78
+ const vexmaps = createVexMaps({ key: process.env.VEX_MAPS_SECRET_KEY });
79
+
80
+ const { results } = await vexmaps.search('castellana', { country: 've' });
81
+ // [{ label: 'La Castellana', kind: 'neighbourhood', precision: 'AREA', point: { lat, lng }, admin: { level1: 'Miranda', level2: 'Chacao' }, … }]
82
+
83
+ const place = await vexmaps.reverse({ lat: 10.5013, lng: -66.8523 }, { country: 've' });
84
+ // { admin, neighbourhood, street, place, inServiceArea, zone, attribution }
85
+
86
+ const countries = await vexmaps.countries(); // secret keys only
87
+ ```
88
+
89
+ Colombian grid addresses work in `search`: `"Calle 72 # 10-34"`, `"Cra 7 con 72"`, `"Kr 24C # 20-10"`, `"Calle 26 Sur # 50-20"`. Pass `near` (the user's area) for the best result.
90
+
91
+ ## Options
92
+
93
+ `createVexMaps({ key, country?, baseUrl?, theme?, styleUrl?, timeoutMs?, fetch? })`
94
+
95
+ - `country`: `'ve'` or `'co'`, the default for every call.
96
+ - `timeoutMs`: default `2000`. A timeout, network failure or server error becomes the `unavailable` error, so the page can fall back to typed fields.
97
+ - `theme`: the map theme, `light` (default), `dark`, `white`, `grayscale` or `purple`.
98
+
99
+ The location picker also takes `pinColor` (any CSS colour, default `#d1372b`) to match your brand: `<LocationPicker pinColor="#5b3fd1" … />` or `mountLocationPicker(el, { client, pinColor: '#5b3fd1' })`. The pin lifts while the map moves and drops back when it stops; with reduced motion it just stays put.
100
+
101
+ ## Map themes
102
+
103
+ | Theme | Style URL |
104
+ |---|---|
105
+ | `light` (default) | `https://tiles.chuventures.com/styles/light.json` |
106
+ | `dark` | `https://tiles.chuventures.com/styles/dark.json` |
107
+ | `white` | `https://tiles.chuventures.com/styles/white.json` |
108
+ | `grayscale` | `https://tiles.chuventures.com/styles/grayscale.json` |
109
+ | `purple` | `https://tiles.chuventures.com/styles/purple.json` |
110
+
111
+ Using the style with MapLibre directly (without the SDK)? Pass `attributionControl: { customAttribution: '' }` so the corner shows only the style's own credit.
112
+
113
+ ## Errors
114
+
115
+ Every failure is a `VexMapsError` with a `code`:
116
+
117
+ | Code | Meaning |
118
+ |---|---|
119
+ | `unavailable` | timeout, network failure or server error: fall back to typed fields |
120
+ | `invalid_api_key` | the key is wrong, revoked or expired |
121
+ | `origin_not_allowed` | a publishable key used from an origin it doesn't allow |
122
+ | `country_not_allowed` | the key's product doesn't have that country |
123
+ | `rate_limited` | too many requests; `retryAfter` is in seconds |
124
+ | `invalid_text` | search text shorter than 3 or longer than 120 characters |
125
+ | `point_outside_country` | a reverse point outside the country |
126
+ | `secret_key_in_browser` | a secret key used in a browser |
127
+ | `secret_key_required` | a publishable key used for a secret-only call (`countries`) |
128
+ | `invalid_country`, `invalid_point` | a country other than `ve`/`co`, or a malformed point |
129
+ | `not_found`, `error` | anything else; `message` says what |
130
+
131
+ ## Text and strings
132
+
133
+ The pieces speak Spanish. Override any label with `strings`, for example `{ placeholder: 'Busca tu dirección' }`. The defaults are in `DEFAULT_STRINGS`.
134
+
135
+ ## Signature and attribution
136
+
137
+ Every map shows **VEX Maps · © OpenStreetMap** in its corner, and the search field shows **Búsqueda por VEX Maps** under its suggestions. The OpenStreetMap credit is required by the data's licence (ODbL). There is no option to hide either, and page CSS can't hide them.
138
+
139
+ ## Privacy
140
+
141
+ Search text and points go in request bodies, never in URLs. VEX Maps uses them to answer that one request and doesn't store or log them.
142
+
143
+ ## Licence
144
+
145
+ MIT. Map data © OpenStreetMap contributors (ODbL), Overture Maps Foundation, GeoNames (CC BY 4.0) and DANE.