@yarrow-uz/yarrow-map-web-sdk 1.0.42 → 1.0.43
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 +62 -49
- package/dist/main.js +1 -1
- package/dist/maps/yarrow.d.ts +1 -0
- package/dist/module.js +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,12 +6,13 @@ This document provides a comprehensive guide to using the Yarrow Map Web SDK for
|
|
|
6
6
|
|
|
7
7
|
- [Getting Started](#getting-started)
|
|
8
8
|
- [Installation](#installation)
|
|
9
|
-
- [React Usage](#react-usage)
|
|
10
9
|
- [Initialization](#initialization)
|
|
11
10
|
- [Configuration Options](#configuration-options)
|
|
11
|
+
- [React Usage](#react-usage)
|
|
12
12
|
- [Basic Map Manipulation](#basic-map-manipulation)
|
|
13
13
|
- [Changing the Map Style](#changing-the-map-style)
|
|
14
14
|
- [Changing the Map Theme](#changing-the-map-theme)
|
|
15
|
+
- [Changing Brand Badge Position](#changing-brand-badge-position)
|
|
15
16
|
- [Moving the Map View](#moving-the-map-view)
|
|
16
17
|
- [Changing Background Color](#changing-background-color)
|
|
17
18
|
- [Handling Events](#handling-events)
|
|
@@ -52,53 +53,6 @@ First, add the Yarrow Map Web SDK to your project using your preferred package m
|
|
|
52
53
|
npm install @yarrow-uz/yarrow-map-web-sdk
|
|
53
54
|
```
|
|
54
55
|
|
|
55
|
-
### React Usage
|
|
56
|
-
|
|
57
|
-
React APIs are exported from the `@yarrow-uz/yarrow-map-web-sdk/react` subpath.
|
|
58
|
-
|
|
59
|
-
```tsx
|
|
60
|
-
import { YarrowMapView } from '@yarrow-uz/yarrow-map-web-sdk/react';
|
|
61
|
-
|
|
62
|
-
export const MapScreen = () => {
|
|
63
|
-
return (
|
|
64
|
-
<YarrowMapView
|
|
65
|
-
config={{
|
|
66
|
-
center: [69.2401, 41.2995],
|
|
67
|
-
zoom: 12,
|
|
68
|
-
brandBadgePosition: 'bottom-left',
|
|
69
|
-
}}
|
|
70
|
-
style={{ width: '100%', height: '600px' }}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
You can also use the hook for custom composition:
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
import { useYarrowMap } from '@yarrow-uz/yarrow-map-web-sdk/react';
|
|
80
|
-
|
|
81
|
-
export const MapScreen = () => {
|
|
82
|
-
const { containerRef, isReady, error } = useYarrowMap({
|
|
83
|
-
config: {
|
|
84
|
-
center: [69.2401, 41.2995],
|
|
85
|
-
zoom: 12,
|
|
86
|
-
brandBadgePosition: 'bottom-right',
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<div>
|
|
92
|
-
<div ref={containerRef} style={{ width: '100%', height: '600px' }} />
|
|
93
|
-
{isReady && <p>Map ready</p>}
|
|
94
|
-
{error && <p>Failed to initialize map</p>}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**SSR note:** The React integration initializes the map only on the client side.
|
|
101
|
-
|
|
102
56
|
### Initialization
|
|
103
57
|
|
|
104
58
|
To get started, you need to create an instance of `YarrowMap`. This requires a configuration object that specifies the container element, center coordinates, and zoom level.
|
|
@@ -177,6 +131,53 @@ yarrowMap.init().then(() => {
|
|
|
177
131
|
|
|
178
132
|
When controls and the brand badge are placed in the same corner (for example `right-bottom` with `brandBadgePosition: 'bottom-right'`), the SDK automatically adds spacing so they do not overlap.
|
|
179
133
|
|
|
134
|
+
### React Usage
|
|
135
|
+
|
|
136
|
+
React APIs are exported from the `@yarrow-uz/yarrow-map-web-sdk/react` subpath.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { YarrowMapView } from '@yarrow-uz/yarrow-map-web-sdk/react';
|
|
140
|
+
|
|
141
|
+
export const MapScreen = () => {
|
|
142
|
+
return (
|
|
143
|
+
<YarrowMapView
|
|
144
|
+
config={{
|
|
145
|
+
center: [69.2401, 41.2995],
|
|
146
|
+
zoom: 12,
|
|
147
|
+
brandBadgePosition: 'bottom-left',
|
|
148
|
+
}}
|
|
149
|
+
style={{ width: '100%', height: '600px' }}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
You can also use the hook for custom composition:
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { useYarrowMap } from '@yarrow-uz/yarrow-map-web-sdk/react';
|
|
159
|
+
|
|
160
|
+
export const MapScreen = () => {
|
|
161
|
+
const { containerRef, isReady, error } = useYarrowMap({
|
|
162
|
+
config: {
|
|
163
|
+
center: [69.2401, 41.2995],
|
|
164
|
+
zoom: 12,
|
|
165
|
+
brandBadgePosition: 'bottom-right',
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<div ref={containerRef} style={{ width: '100%', height: '600px' }} />
|
|
172
|
+
{isReady && <p>Map ready</p>}
|
|
173
|
+
{error && <p>Failed to initialize map</p>}
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**SSR note:** The React integration initializes the map only on the client side.
|
|
180
|
+
|
|
180
181
|
## Basic Map Manipulation
|
|
181
182
|
|
|
182
183
|
### Changing the Map Style
|
|
@@ -230,6 +231,17 @@ await yarrowMap.changeTheme('light');
|
|
|
230
231
|
- Preserves custom icons and markers
|
|
231
232
|
- Seamless theme transition
|
|
232
233
|
|
|
234
|
+
### Changing Brand Badge Position
|
|
235
|
+
|
|
236
|
+
You can set the initial badge position in config or change it dynamically after map initialization.
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
// Move badge to the top-right corner
|
|
240
|
+
yarrowMap.changeBrandBadgePosition('top-right');
|
|
241
|
+
|
|
242
|
+
// Other values: 'top-left' | 'bottom-left' | 'bottom-right'
|
|
243
|
+
```
|
|
244
|
+
|
|
233
245
|
### Moving the Map View
|
|
234
246
|
|
|
235
247
|
You can programmatically move the map to a new location or fit it to a specific geographic area.
|
|
@@ -951,6 +963,7 @@ constructor(
|
|
|
951
963
|
| `init()` | None | `Promise<void>` | Initialize the map with styles and icons |
|
|
952
964
|
| `changeStyles(styleType?)` | `styleType?: 'satellite' \| 'hybrid'` | `Promise<any>` | Change map style |
|
|
953
965
|
| `changeTheme(theme)` | `theme: 'light' \| 'dark'` | `Promise<any>` | Switch between light and dark themes |
|
|
966
|
+
| `changeBrandBadgePosition(position)` | `position: 'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right'` | `BrandBadgePosition` | Change brand badge corner position at runtime |
|
|
954
967
|
| `zoomTo(lat, lng, zoom)` | `lat: number, lng: number, zoom: number` | `void` | Fly to specific coordinates |
|
|
955
968
|
| `fitBounds(data)` | `data: GeoJSON` | `void` | Fit map to show all features |
|
|
956
969
|
| `getBoundingBox(data)` | `data: GeoJSON` | `BoundingBox` | Calculate bounding box of features |
|
|
@@ -1014,7 +1027,7 @@ interface SearchOptions {
|
|
|
1014
1027
|
|
|
1015
1028
|
## Version Information
|
|
1016
1029
|
|
|
1017
|
-
- **Current Version**: 1.0.
|
|
1030
|
+
- **Current Version**: 1.0.43
|
|
1018
1031
|
- **Dependencies**: maplibre-gl ^5.5.0, axios ^1.7.9
|
|
1019
1032
|
- **Repository**: https://git.yarrow.uz/yarrow-sdk/frontend/yarrow-map-web-sdk
|
|
1020
1033
|
- **Changelog**: `CHANGELOG.md`
|