1import { PropsWithChildren } from 'react'; 2import { ViewProps } from 'react-native'; 3 4import { CircleObject } from './Circle'; 5import { ClusterObject } from './Cluster'; 6import { CameraMove, LocationChangePriority } from './Common.types'; 7import { 8 ClusterPressEvent, 9 MarkerEvent, 10 OnLocationButtonPressEvent, 11 OnLocationChangeEvent, 12 OnLocationDotPressEvent, 13 OnPoiClickEvent, 14 OnRegionChangeEvent, 15} from './Events'; 16import { GeoJsonObject } from './GeoJson'; 17import { HeatmapObject } from './Heatmap'; 18import { KMLObject } from './KML'; 19import { ExpoMap, OnMapPressEvent } from './Map'; 20import { MarkerObject } from './Marker'; 21import { OverlayObject } from './Overlay'; 22import { PolygonObject } from './Polygon'; 23import { PolylineObject } from './Polyline'; 24export type MapTypes = 'normal' | 'hybrid' | 'satellite' | 'terrain'; 25 26/** 27 * Prop for managing map type. 28 */ 29export type MapType = { 30 /** 31 * Type of map (one of normal, hybrid, satellite, terrain'). 32 * 33 * @default 'normal' 34 */ 35 mapType: MapTypes; 36}; 37 38/** 39 * Internal prop for managing markers displayed on the map. 40 */ 41export type Markers = { 42 /** 43 * Array of {@link MarkerObject}. 44 */ 45 markers: MarkerObject[]; 46}; 47 48/** 49 * Internal prop for managing polygons displayed on the map. 50 */ 51export type Polygons = { 52 /** 53 * Array of {@link PolygonObject}. 54 */ 55 polygons: PolygonObject[]; 56}; 57 58/** 59 * Internal prop for managing polylines displayed on the map. 60 */ 61export type Polylines = { 62 /** 63 * Array of {@link PolylineObject}. 64 */ 65 polylines: PolylineObject[]; 66}; 67 68/** 69 * Internal prop for managing overlays displayed on the map. 70 */ 71export type Overlays = { 72 /** 73 * Array of {@link OverlayObject}. 74 */ 75 overlays: OverlayObject[]; 76}; 77 78/** 79 * Internal prop for managing circles displayed on the map. 80 */ 81export type Circles = { 82 /** 83 * Array of {@link CircleObject}. 84 */ 85 circles: CircleObject[]; 86}; 87 88/** 89 * Internal prop for managing clusters displayed on the map. 90 */ 91export type Clusters = { 92 /** 93 * Array of {@link ClusterObject}. 94 */ 95 clusters: ClusterObject[]; 96}; 97 98/** 99 * Internal prop for managing provided KMLs 100 */ 101export type KMLs = { 102 /** 103 * Array of {@link KMLObject} 104 */ 105 kmls: KMLObject[]; 106}; 107 108/** 109 * Internal prop for managing provided KMLs 110 */ 111export type GeoJsons = { 112 /** 113 * Array of {@link GeoJsonObject} 114 */ 115 geojsons: GeoJsonObject[]; 116}; 117 118/** 119 * Prop for managing Google Maps styling settings. 120 */ 121export type GoogleMapsStyling = { 122 /** 123 * Valid Google Maps style JSON string, 124 * please use https://mapstyle.withgoogle.com to generate style JSONs. 125 * 126 * This prop works only when provider == `google`. 127 */ 128 googleMapsJsonStyleString: string; 129}; 130 131/** 132 * Props for managing map gestures settings. 133 */ 134export type Gestures = { 135 /** 136 * If `true` rotate gestures are enabled. 137 * 138 * @default false 139 */ 140 enableRotateGestures: boolean; 141 /** 142 * If `true` scroll gestures are enabled. 143 * 144 * @default true 145 */ 146 enableScrollGestures: boolean; 147 /** 148 * If `true` tilt gestures are enabled. 149 * 150 * @default false 151 */ 152 enableTiltGestures: boolean; 153 /** 154 * If `true` zoom gestures are enabled. 155 * 156 * @default true 157 */ 158 enableZoomGestures: boolean; 159}; 160 161/** 162 * Props for managing map controls settings. 163 */ 164export type Controls = { 165 /** 166 * If `true` zoom controls are visible. 167 * 168 * This prop works only when provider == `google`. 169 * 170 * @default true 171 */ 172 showZoomControls: boolean; 173 /** 174 * If `true` compass icon can be visible. 175 * 176 * It appears only when map is moved so that it is not facing north. 177 * 178 * @default true 179 */ 180 showCompass: boolean; 181 /** 182 * If `true` map toolbar can be visible. 183 * 184 * It is visible when a marker is tapped and hidden when the marker is no longer in focus. 185 * 186 * This prop works only when provider == `google`. 187 * 188 * @default true 189 */ 190 showMapToolbar: boolean; 191 /** 192 * If `true` map toolbar can be visible. 193 * 194 * It is visble when map can access user location. 195 * 196 * @default true 197 */ 198 showMyLocationButton: boolean; 199 /** 200 * TODO when functionality fully added 201 * 202 * @default true 203 */ 204 showLevelPicker: boolean; 205}; 206 207/** 208 * Props for managing traffic layer. 209 */ 210export type Traffic = { 211 /** 212 * If `true` traffic data is displayed on map. 213 * 214 * @default false 215 */ 216 enableTraffic: boolean; 217}; 218 219/** 220 * Props for callback events. 221 */ 222export type Callbacks = { 223 /** 224 * Callback to call when the map is loaded. 225 * 226 * @default () => {} 227 */ 228 onMapLoaded?: () => void; 229 230 /** 231 * Callback to call when user clicks on the map. 232 * 233 * @default () => {} 234 */ 235 onMapPress?: (event: OnMapPressEvent) => void; 236 237 /** 238 * Callback to call when the user double presses the map 239 * 240 * @default () => {} 241 */ 242 onDoublePress?: (event: OnMapPressEvent) => void; 243 244 /** 245 * Callback to call when the user long presses the map 246 * 247 * @default () => {} 248 */ 249 onLongPress?: (event: OnMapPressEvent) => void; 250 251 /** 252 * Callback to call when camera is moving. 253 * 254 * @default (event: OnRegionChangeEvent) => {} 255 */ 256 onRegionChange?: (event: OnRegionChangeEvent) => void; 257 258 /** 259 * Callback to call when camera has started moving. 260 * 261 * @default (event: OnRegionChangeEvent) => {} 262 */ 263 onRegionChangeStarted?: (event: OnRegionChangeEvent) => void; 264 265 /** 266 * Callback to call when camera has stopped moving. 267 * 268 * @default (event: OnRegionChangeEvent) => {} 269 */ 270 onRegionChangeComplete?: (event: OnRegionChangeEvent) => void; 271 272 /** 273 * Callback to call when the user presses a point of interest. 274 * 275 * @default (event: OnRegionChangeEvent) => {} 276 */ 277 onPoiClick?: (event: OnPoiClickEvent) => void; 278 279 /** 280 * Callback to call when the user presses a marker 281 * 282 * @default (event: MarkerEvent) => {} 283 */ 284 onMarkerPress?: (event: MarkerEvent) => void; 285 286 /** 287 * Callback to call on every position update of a marker. 288 * 289 * @default (event: MarkerEvent) => {} 290 */ 291 onMarkerDrag?: (event: MarkerEvent) => void; 292 293 /** 294 * Callback to call when the user started moving a marker. 295 * 296 * @default (event: OnMarkerDragStarted) => {} 297 */ 298 onMarkerDragStarted?: (event: MarkerEvent) => void; 299 300 /** 301 * Callback to call when the user ended moving a marker. 302 * 303 * @default (event: MarkerEvent) => {} 304 */ 305 onMarkerDragComplete?: (event: MarkerEvent) => void; 306 307 /** 308 * Callback to call when the user presses on a cluster. 309 * 310 * @default (event: ClusterPressEvent) => {} 311 */ 312 onClusterPress?: (event: ClusterPressEvent) => void; 313 314 /** 315 * Callback to call when the user presses the current location dot. 316 * Not supported on `iOS GoogleMaps` 317 * @default (event: OnLocationDotPressEvent) => {} 318 */ 319 onLocationDotPress?: (event: OnLocationDotPressEvent) => void; 320 321 /** 322 * Callback to call when the user presses the location button. 323 * 324 * @default (event: OnLocationButtonPressEvent) => {} 325 */ 326 onLocationButtonPress?: (event: OnLocationButtonPressEvent) => void; 327 328 /** 329 * Callback to call when a change in user's location is detected 330 * @default (event: OnLocationChangeEvent) => {} 331 */ 332 onLocationChange?: (event: OnLocationChangeEvent) => void; 333 334 /** 335 * Value in milliseconds describing how often the onLocationChangeCallback will check if the user location has changed. 336 * Reducing this value might have negative impact on battery life 337 * @default 5000 338 */ 339 onLocationChangeEventInterval?: number; 340 341 /** 342 * Determines how accurate requests for location change event should be 343 * @default LocationChangePriority.PRIORITY_NO_POWER 344 */ 345 onLocationChangeEventPriority?: LocationChangePriority; 346}; 347 348export type POICategoryType = 349 | 'airport' 350 | 'atm' 351 | 'bank' 352 | 'beach' 353 | 'cafe' 354 | 'hospital' 355 | 'hotel' 356 | 'museum' 357 | 'pharmacy' 358 | 'store'; 359 360/** 361 * Props for POI handling. 362 */ 363export type POI = { 364 /** 365 * If 'true' search bar for searching pois is enabled. 366 * 367 * This prop works only when provider == `apple`. 368 * 369 * @default false 370 */ 371 enablePOISearching: boolean; 372 /** 373 * If 'true' points of interest are being displayed. 374 * 375 * @default false 376 */ 377 enablePOIs: boolean; 378 /** 379 * If not empty POIs use will be filterd to specified types. 380 * 381 * This prop works only when provider == `apple`. 382 * 383 * @default [] 384 */ 385 enablePOIFilter: [POICategoryType] | []; 386 387 /** 388 * Creates a search request for given place. 389 * 390 * Passed value shoulld be a result of auto complete. 391 * 392 */ 393 createPOISearchRequest: string; 394 /** 395 * If `true` POIs are clickable and after the click name of POI is displayed above the POI's location. 396 * Please note, this field is only effective when `enablePOI` option is equal to `true`. 397 * 398 * @default false 399 */ 400 clickablePOIs: boolean; 401}; 402 403export type AppleMapsPOI = POI; 404export type GoogleMapsPOI = Omit<POI, 'enablePOISearching' | 'enablePOIFilter'>; 405export type Heatmaps = { 406 /** 407 * Array of {@link HeatmapObject}. 408 */ 409 heatmaps: HeatmapObject[]; 410}; 411 412export type GoogleMapsControls = Controls; 413 414export type ZoomLevels = 415 | 1 416 | 2 417 | 3 418 | 4 419 | 5 420 | 6 421 | 7 422 | 8 423 | 9 424 | 10 425 | 11 426 | 12 427 | 13 428 | 14 429 | 15 430 | 16 431 | 17 432 | 18 433 | 19 434 | 20 435 | 21 436 | 22; 437 438/** 439 * Prop for setting camera position. 440 */ 441export type CameraPosition = { 442 /** 443 * Camera position object 444 * 445 * @default 446 * { 447 * latitude: 51.51, 448 * longitude: 0.13, 449 * zoom: 4, 450 * animate: true, 451 * } 452 */ 453 initialCameraPosition: CameraMove; 454}; 455 456export type AppleMapsControls = Omit<Controls, 'showMapToolbar' | 'showZoomControls'>; 457 458/** 459 * Props for Google Maps implementation. 460 */ 461export type NativeExpoGoogleMapsViewProps = ViewProps & 462 React.RefAttributes<ExpoMap> & 463 PropsWithChildren< 464 MapType & 465 GoogleMapsStyling & 466 Gestures & 467 Markers & 468 Polygons & 469 Polylines & 470 GoogleMapsControls & 471 CameraPosition & 472 Circles & 473 Clusters & 474 Traffic & 475 KMLs & 476 GeoJsons & 477 GoogleMapsPOI & 478 Overlays & 479 Heatmaps & 480 Callbacks 481 >; 482 483/** 484 * Props for Apple Maps implementation. 485 */ 486export type NativeExpoAppleMapsViewProps = ViewProps & 487 React.RefAttributes<ExpoMap> & 488 PropsWithChildren< 489 MapType & 490 Gestures & 491 Markers & 492 Polygons & 493 Polylines & 494 AppleMapsControls & 495 CameraPosition & 496 Circles & 497 Clusters & 498 Traffic & 499 KMLs & 500 GeoJsons & 501 AppleMapsPOI 502 >; 503 504export type ExpoMapRef = { 505 getSearchCompletions: () => Promise<void>; 506 moveCamera: () => Promise<CameraPosition>; 507}; 508 509export type Providers = 'google' | 'apple'; 510 511/** 512 * Prop for managing map provider. 513 */ 514export type Provider = { 515 /** 516 * Provider you want to use for your map, please note `apple` provider is only avaliable on Apple devices. 517 * 518 * @default 'google' 519 */ 520 provider: Providers; 521}; 522 523/** 524 * General Expo Map props. 525 * 526 * All of the ExpoMap props are optional. 527 */ 528export type ExpoMapViewProps = ViewProps & 529 PropsWithChildren< 530 Partial< 531 Provider & 532 MapType & 533 Controls & 534 GoogleMapsStyling & 535 Gestures & 536 CameraPosition & 537 Traffic & 538 POI & 539 KMLs & 540 Heatmaps & 541 Callbacks 542 > 543 >; 544 545export type DefaultNativeExpoMapViewProps = MapType & 546 Controls & 547 Gestures & 548 CameraPosition & 549 Traffic & 550 POI; 551 552export type ExpoMapState = Markers & 553 Polygons & 554 Polylines & 555 Circles & 556 Clusters & 557 KMLs & 558 GeoJsons & 559 Overlays & 560 Heatmaps; 561