maplibre-gl-basemap-control 0.2.1 → 0.3.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/README.md +48 -1
- package/dist/{BasemapControl-Bgd4nl0C.js → BasemapControl-DD97GXiq.js} +605 -29
- package/dist/BasemapControl-DD97GXiq.js.map +1 -0
- package/dist/{BasemapControl-B6fW3kYQ.cjs → BasemapControl-DrZ_VXsL.cjs} +605 -29
- package/dist/BasemapControl-DrZ_VXsL.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/maplibre-gl-basemap-control.css +32 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/core/BasemapControl.d.ts +23 -1
- package/dist/types/lib/core/BasemapControl.d.ts.map +1 -1
- package/dist/types/lib/core/catalog.d.ts.map +1 -1
- package/dist/types/lib/core/types.d.ts +10 -0
- package/dist/types/lib/core/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/BasemapControl-B6fW3kYQ.cjs.map +0 -1
- package/dist/BasemapControl-Bgd4nl0C.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ A MapLibre GL JS control for searching and switching public basemaps. It keeps t
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- Search-first basemap picker inspired by QuickMapServices
|
|
11
|
-
- Built-in
|
|
11
|
+
- Built-in catalog for common public basemaps, MapTiler styles, Amazon Location styles, and Mapbox styles
|
|
12
12
|
- Custom basemap and provider definitions
|
|
13
13
|
- MapLibre `IControl` implementation
|
|
14
14
|
- React wrapper and state hook
|
|
@@ -131,6 +131,46 @@ const control = new BasemapControl({
|
|
|
131
131
|
|
|
132
132
|
Set `includeDefaultBasemaps: false` to use only your supplied catalog.
|
|
133
133
|
|
|
134
|
+
## Keyed Provider Styles
|
|
135
|
+
|
|
136
|
+
The built-in catalog includes MapTiler styles such as Streets, Base, Dataviz, Outdoor, Topo,
|
|
137
|
+
Satellite Hybrid, Satellite Plain, Aquarelle, Backdrop, Landscape, Ocean, Toner, OpenStreetMap, and
|
|
138
|
+
Winter. It also includes Amazon Location styles: Standard, Monochrome, Hybrid, and Satellite.
|
|
139
|
+
Mapbox styles include Streets, Outdoors, Light, Dark, Satellite, Satellite Streets, Navigation Day,
|
|
140
|
+
and Navigation Night.
|
|
141
|
+
|
|
142
|
+
MapTiler and Amazon Location styles require API keys. Mapbox styles require an access token. Users
|
|
143
|
+
can enter keys and tokens in the collapsible provider settings section in the control panel, or you
|
|
144
|
+
can provide them when creating the control.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const control = new BasemapControl({
|
|
148
|
+
defaultBasemapId: 'maptiler-streets',
|
|
149
|
+
mapTilerApiKey: 'YOUR_MAPTILER_API_KEY',
|
|
150
|
+
amazonApiKey: 'YOUR_AMAZON_LOCATION_API_KEY',
|
|
151
|
+
awsRegion: 'us-east-1',
|
|
152
|
+
mapboxAccessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The default MapTiler style URLs follow this form:
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
https://api.maptiler.com/maps/{mapId}/style.json?key={api-key}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Amazon Location style URLs follow this form:
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
https://maps.geo.{aws-region}.amazonaws.com/v2/styles/{mapStyle}/descriptor?key={api-key}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Mapbox style URLs follow this form:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
https://api.mapbox.com/styles/v1/mapbox/{styleId}?access_token={api-key}
|
|
172
|
+
```
|
|
173
|
+
|
|
134
174
|
## API
|
|
135
175
|
|
|
136
176
|
### BasemapControl Options
|
|
@@ -142,6 +182,10 @@ Set `includeDefaultBasemaps: false` to use only your supplied catalog.
|
|
|
142
182
|
| `title` | `string` | `'Basemaps'` | Panel title and button label |
|
|
143
183
|
| `panelWidth` | `number` | `340` | Floating panel width in pixels |
|
|
144
184
|
| `className` | `string` | `''` | Extra class for the control button container |
|
|
185
|
+
| `mapTilerApiKey` | `string` | `undefined` | Initial MapTiler API key for built-in MapTiler styles |
|
|
186
|
+
| `amazonApiKey` | `string` | `undefined` | Initial Amazon Location API key for built-in Amazon styles |
|
|
187
|
+
| `awsRegion` | `string` | `'us-east-1'` | AWS region for built-in Amazon Location styles |
|
|
188
|
+
| `mapboxAccessToken` | `string` | `undefined` | Initial Mapbox access token for built-in Mapbox styles |
|
|
145
189
|
| `basemaps` | `BasemapDefinition[]` | `[]` | Custom basemaps to add or use |
|
|
146
190
|
| `providers` | `BasemapProvider[]` | `[]` | Custom provider labels |
|
|
147
191
|
| `includeDefaultBasemaps` | `boolean` | `true` | Include the built-in public catalog |
|
|
@@ -150,6 +194,9 @@ Set `includeDefaultBasemaps: false` to use only your supplied catalog.
|
|
|
150
194
|
### Methods
|
|
151
195
|
|
|
152
196
|
- `setBasemap(id)` - Apply a basemap and remove the previous plugin-managed basemap
|
|
197
|
+
- `setMapTilerApiKey(apiKey)` - Set or update the MapTiler API key used by MapTiler styles
|
|
198
|
+
- `setAmazonCredentials(apiKey, awsRegion)` - Set or update Amazon Location credentials
|
|
199
|
+
- `setMapboxAccessToken(accessToken)` - Set or update the Mapbox access token
|
|
153
200
|
- `getActiveBasemap()` - Return the current basemap definition
|
|
154
201
|
- `getBasemaps()` - Return the catalog
|
|
155
202
|
- `setBasemaps(basemaps)` - Replace the catalog
|