-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
pigeon.dart
348 lines (287 loc) · 7.86 KB
/
pigeon.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/src/platform/pigeon.g.dart',
dartOptions: DartOptions(),
dartPackageName: 'maplibre',
// linux
gobjectHeaderOut: 'linux/pigeon.g.h',
gobjectSourceOut: 'linux/pigeon.g.cc',
gobjectOptions: GObjectOptions(),
// windows
cppOptions: CppOptions(namespace: 'pigeon_maplibre'),
cppHeaderOut: 'windows/runner/pigeon.g.h',
cppSourceOut: 'windows/runner/pigeon.g.cpp',
// android
kotlinOut: 'android/src/main/kotlin/com/github/josxha/maplibre/Pigeon.g.kt',
kotlinOptions: KotlinOptions(),
// ios
swiftOut: 'ios/Classes/Pigeon.g.swift',
swiftOptions: SwiftOptions(),
),
)
@HostApi()
abstract interface class MapLibreHostApi {
/// Add a fill layer to the map style.
@async
void addFillLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a circle layer to the map style.
@async
void addCircleLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a background layer to the map style.
@async
void addBackgroundLayer({
required String id,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a fill extrusion layer to the map style.
@async
void addFillExtrusionLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a heatmap layer to the map style.
@async
void addHeatmapLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a hillshade layer to the map style.
@async
void addHillshadeLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a line layer to the map style.
@async
void addLineLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a raster layer to the map style.
@async
void addRasterLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Add a symbol layer to the map style.
@async
void addSymbolLayer({
required String id,
required String sourceId,
required Map<String, Object> layout,
required Map<String, Object> paint,
String? belowLayerId,
});
/// Loads an image to the map. An image needs to be loaded before it can
/// get used.
@async
Uint8List loadImage(String url);
/// Add an image to the map.
@async
void addImage(String id, Uint8List bytes);
}
@FlutterApi()
abstract interface class MapLibreFlutterApi {
/// Get the map options from dart.
MapOptions getOptions();
/// Callback for when the style has been loaded.
void onStyleLoaded();
/// Callback for when the map is ready and can be used.
void onMapReady();
/// Callback when the user clicks on the map.
void onClick(LngLat point);
/// Callback when the map idles.
void onIdle();
/// Callback when the map camera idles.
void onCameraIdle();
/// Callback when the user performs a secondary click on the map
/// (e.g. by default a click with the right mouse button).
void onSecondaryClick(LngLat point);
/// Callback when the user performs a double click on the map.
void onDoubleClick(LngLat point);
/// Callback when the user performs a long lasting click on the map.
void onLongClick(LngLat point);
/// Callback when the map camera changes.
void onMoveCamera(MapCamera camera);
/// Callback when the map camera starts changing.
void onStartMoveCamera(CameraChangeReason reason);
}
@HostApi()
// ignore: one_member_abstracts
abstract interface class PermissionManagerHostApi {
/// Request location permissions.
@async
bool requestLocationPermissions({
required String explanation,
});
}
/// The map options define initial values for the MapLibre map.
class MapOptions {
const MapOptions({
required this.style,
required this.zoom,
required this.center,
required this.pitch,
required this.bearing,
required this.maxBounds,
required this.minZoom,
required this.maxZoom,
required this.minPitch,
required this.maxPitch,
required this.gestures,
required this.androidTextureMode,
});
/// The URL of the used map style.
final String style;
/// The initial zoom level of the map.
final double zoom;
/// The initial pitch / tilt of the map.
final double pitch;
/// The initial bearing of the map.
final double bearing;
/// The initial center coordinates of the map.
final LngLat? center;
/// The maximum bounding box of the map camera.
final LngLatBounds? maxBounds;
/// The minimum zoom level of the map.
final double minZoom;
/// The maximum zoom level of the map.
final double maxZoom;
/// The minimum pitch / tilt of the map.
final double minPitch;
/// The maximum pitch / tilt of the map.
final double maxPitch;
/// The map gestures.
final MapGestures gestures;
/// Toggle the texture mode on android.
final bool androidTextureMode;
}
/// Map gestures
class MapGestures {
/// Create a new [MapGestures] object by setting all gestures.
const MapGestures({
required this.rotate,
required this.pan,
required this.zoom,
required this.tilt,
});
/// Rotate the map bearing.
final bool rotate;
/// Move the center of the map around.
final bool pan;
/// Zoom the map in and out.
final bool zoom;
/// Tilt (pitch) the map camera.
final bool tilt;
}
/// A longitude/latitude coordinate object.
class LngLat {
const LngLat({required this.lng, required this.lat});
/// The longitude
final double lng;
/// The latitude
final double lat;
}
/// A pixel location / location on the device screen.
class Offset {
const Offset({required this.x, required this.y});
/// The x coordinate
final double x;
/// The y coordinate
final double y;
}
/// Camera Padding
class Padding {
const Padding({
required this.top,
required this.bottom,
required this.left,
required this.right,
});
final int top;
final int bottom;
final int left;
final int right;
}
/// The current position of the map camera.
class MapCamera {
const MapCamera({
required this.center,
required this.zoom,
required this.pitch,
required this.bearing,
});
final LngLat center;
final double zoom;
final double pitch;
final double bearing;
}
/// LatLng bound object
class LngLatBounds {
const LngLatBounds({
required this.longitudeWest,
required this.longitudeEast,
required this.latitudeSouth,
required this.latitudeNorth,
});
final double longitudeWest;
final double longitudeEast;
final double latitudeSouth;
final double latitudeNorth;
}
/// Influences the y direction of the tile coordinates.
enum TileScheme {
/// Slippy map tilenames scheme.
xyz,
/// OSGeo spec scheme.
tms;
}
/// The encoding used by this source. Mapbox Terrain RGB is used by default.
enum RasterDemEncoding {
/// Terrarium format PNG tiles.
terrarium,
/// Mapbox Terrain RGB tiles.
mapbox,
/// Decodes tiles using the redFactor, blueFactor, greenFactor, baseShift
/// parameters.
custom;
}
/// The reason the camera is changing.
enum CameraChangeReason {
/// Developer animation.
developerAnimation,
/// API animation.
apiAnimation,
/// API gesture
apiGesture;
}