Spaces:
Sleeping
Sleeping
File size: 44,059 Bytes
b593f0b | 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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 | // @flow
import {Event} from '../util/evented';
import DOM from '../util/dom';
import Point from '@mapbox/point-geometry';
import {extend} from '../util/util';
import type Map from './map';
import type LngLat from '../geo/lng_lat';
/**
* `MapMouseEvent` is the event type for mouse-related map events.
* @extends {Object}
* @example
* // The `click` event is an example of a `MapMouseEvent`.
* // Set up an event listener on the map.
* map.on('click', function(e) {
* // The event object (e) contains information like the
* // coordinates of the point on the map that was clicked.
* console.log('A click event has occurred at ' + e.lngLat);
* });
*/
export class MapMouseEvent extends Event {
/**
* The event type (one of {@link Map.event:mousedown},
* {@link Map.event:mouseup},
* {@link Map.event:click},
* {@link Map.event:dblclick},
* {@link Map.event:mousemove},
* {@link Map.event:mouseover},
* {@link Map.event:mouseenter},
* {@link Map.event:mouseleave},
* {@link Map.event:mouseout},
* {@link Map.event:contextmenu}).
*/
type: 'mousedown'
| 'mouseup'
| 'click'
| 'dblclick'
| 'mousemove'
| 'mouseover'
| 'mouseenter'
| 'mouseleave'
| 'mouseout'
| 'contextmenu';
/**
* The `Map` object that fired the event.
*/
target: Map;
/**
* The DOM event which caused the map event.
*/
originalEvent: MouseEvent;
/**
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
*/
point: Point;
/**
* The geographic location on the map of the mouse cursor.
*/
lngLat: LngLat;
/**
* Prevents subsequent default processing of the event by the map.
*
* Calling this method will prevent the following default map behaviors:
*
* * On `mousedown` events, the behavior of {@link DragPanHandler}
* * On `mousedown` events, the behavior of {@link DragRotateHandler}
* * On `mousedown` events, the behavior of {@link BoxZoomHandler}
* * On `dblclick` events, the behavior of {@link DoubleClickZoomHandler}
*
*/
preventDefault() {
this._defaultPrevented = true;
}
/**
* `true` if `preventDefault` has been called.
* @private
*/
get defaultPrevented(): boolean {
return this._defaultPrevented;
}
_defaultPrevented: boolean;
/**
* @private
*/
constructor(type: string, map: Map, originalEvent: MouseEvent, data: Object = {}) {
const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
const lngLat = map.unproject(point);
super(type, extend({point, lngLat, originalEvent}, data));
this._defaultPrevented = false;
this.target = map;
}
}
/**
* `MapTouchEvent` is the event type for touch-related map events.
* @extends {Object}
*/
export class MapTouchEvent extends Event {
/**
* The event type.
*/
type: 'touchstart'
| 'touchend'
| 'touchcancel';
/**
* The `Map` object that fired the event.
*/
target: Map;
/**
* The DOM event which caused the map event.
*/
originalEvent: TouchEvent;
/**
* The geographic location on the map of the center of the touch event points.
*/
lngLat: LngLat;
/**
* The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left
* corner.
*/
point: Point;
/**
* The array of pixel coordinates corresponding to a
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
*/
points: Array<Point>;
/**
* The geographical locations on the map corresponding to a
* [touch event's `touches`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/touches) property.
*/
lngLats: Array<LngLat>;
/**
* Prevents subsequent default processing of the event by the map.
*
* Calling this method will prevent the following default map behaviors:
*
* * On `touchstart` events, the behavior of {@link DragPanHandler}
* * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
*
*/
preventDefault() {
this._defaultPrevented = true;
}
/**
* `true` if `preventDefault` has been called.
* @private
*/
get defaultPrevented(): boolean {
return this._defaultPrevented;
}
_defaultPrevented: boolean;
/**
* @private
*/
constructor(type: string, map: Map, originalEvent: TouchEvent) {
const touches = type === "touchend" ? originalEvent.changedTouches : originalEvent.touches;
const points = DOM.touchPos(map.getCanvasContainer(), touches);
const lngLats = points.map((t) => map.unproject(t));
const point = points.reduce((prev, curr, i, arr) => {
return prev.add(curr.div(arr.length));
}, new Point(0, 0));
const lngLat = map.unproject(point);
super(type, {points, point, lngLats, lngLat, originalEvent});
this._defaultPrevented = false;
}
}
/**
* `MapWheelEvent` is the event type for the `wheel` map event.
* @extends {Object}
*/
export class MapWheelEvent extends Event {
/**
* The event type.
*/
type: 'wheel';
/**
* The `Map` object that fired the event.
*/
target: Map;
/**
* The DOM event which caused the map event.
*/
originalEvent: WheelEvent;
/**
* Prevents subsequent default processing of the event by the map.
*
* Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
*/
preventDefault() {
this._defaultPrevented = true;
}
/**
* `true` if `preventDefault` has been called.
* @private
*/
get defaultPrevented(): boolean {
return this._defaultPrevented;
}
_defaultPrevented: boolean;
/**
* @private
*/
constructor(type: string, map: Map, originalEvent: WheelEvent) {
super(type, {originalEvent});
this._defaultPrevented = false;
}
}
/**
* A `MapBoxZoomEvent` is the event type for the boxzoom-related map events emitted by the {@link BoxZoomHandler}.
*
* @typedef {Object} MapBoxZoomEvent
* @property {MouseEvent} originalEvent The DOM event that triggered the boxzoom event. Can be a `MouseEvent` or `KeyboardEvent`
* @property {string} type The type of boxzoom event. One of `boxzoomstart`, `boxzoomend` or `boxzoomcancel`
* @property {Map} target The `Map` instance that triggerred the event
*/
export type MapBoxZoomEvent = {
type: 'boxzoomstart'
| 'boxzoomend'
| 'boxzoomcancel',
target: Map,
originalEvent: MouseEvent
};
/**
* A `MapDataEvent` object is emitted with the {@link Map.event:data}
* and {@link Map.event:dataloading} events. Possible values for
* `dataType`s are:
*
* - `'source'`: The non-tile data associated with any source
* - `'style'`: The [style](https://www.mapbox.com/mapbox-gl-style-spec/) used by the map
*
* @typedef {Object} MapDataEvent
* @property {string} type The event type.
* @property {string} dataType The type of data that has changed. One of `'source'`, `'style'`.
* @property {boolean} [isSourceLoaded] True if the event has a `dataType` of `source` and the source has no outstanding network requests.
* @property {Object} [source] The [style spec representation of the source](https://www.mapbox.com/mapbox-gl-style-spec/#sources) if the event has a `dataType` of `source`.
* @property {string} [sourceDataType] Included if the event has a `dataType` of `source` and the event signals
* that internal data has been received or changed. Possible values are `metadata`, `content` and `visibility`.
* @property {Object} [tile] The tile being loaded or changed, if the event has a `dataType` of `source` and
* the event is related to loading of a tile.
* @property {Coordinate} [coord] The coordinate of the tile if the event has a `dataType` of `source` and
* the event is related to loading of a tile.
* @example
* // The sourcedata event is an example of MapDataEvent.
* // Set up an event listener on the map.
* map.on('sourcedata', function(e) {
* if (e.isSourceLoaded) {
* // Do something when the source has finished loading
* }
* });
*/
export type MapDataEvent = {
type: string,
dataType: string
};
export type MapContextEvent = {
type: 'webglcontextlost' | 'webglcontextrestored',
originalEvent: WebGLContextEvent
}
export type MapEvent =
/**
* Fired when a pointing device (usually a mouse) is pressed within the map.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
* the cursor is pressed while inside a visible portion of the specifed layer.
*
* @event mousedown
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('mousedown', function() {
* console.log('A mousedown event has occurred.');
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('mousedown', 'poi-label', function() {
* console.log('A mousedown event has occurred on a visible portion of the poi-label layer.');
* });
* @see [Highlight features within a bounding box](https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)
* @see [Create a draggable point](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-point/)
*/
| 'mousedown'
/**
* Fired when a pointing device (usually a mouse) is released within the map.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
* the cursor is released while inside a visible portion of the specifed layer.
*
* @event mouseup
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('mouseup', function() {
* console.log('A mouseup event has occurred.');
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('mouseup', 'poi-label', function() {
* console.log('A mouseup event has occurred on a visible portion of the poi-label layer.');
* });
* @see [Highlight features within a bounding box](https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)
* @see [Create a draggable point](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-point/)
*/
| 'mouseup'
/**
* Fired when a pointing device (usually a mouse) is moved within the map.
* As you move the cursor across a web page containing a map,
* the event will fire each time it enters the map or any child elements.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
* the cursor is moved inside a visible portion of the specifed layer.
*
* @event mouseover
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('mouseover', function() {
* console.log('A mouseover event has occurred.');
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('mouseover', 'poi-label', function() {
* console.log('A mouseover event has occurred on a visible portion of the poi-label layer.');
* });
* @see [Get coordinates of the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/mouse-position/)
* @see [Highlight features under the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/hover-styles/)
* @see [Display a popup on hover](https://www.mapbox.com/mapbox-gl-js/example/popup-on-hover/)
*/
| 'mouseover'
/**
* Fired when a pointing device (usually a mouse) is moved while the cursor is inside the map.
* As you move the cursor across the map, the event will fire every time the cursor changes position within the map.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
* the cursor is inside a visible portion of the specified layer.
*
* @event mousemove
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('mousemove', function() {
* console.log('A mousemove event has occurred.');
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('mousemove', 'poi-label', function() {
* console.log('A mousemove event has occurred on a visible portion of the poi-label layer.');
* });
* @see [Get coordinates of the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/mouse-position/)
* @see [Highlight features under the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/hover-styles/)
* @see [Display a popup on over](https://www.mapbox.com/mapbox-gl-js/example/popup-on-hover/)
*/
| 'mousemove'
/**
* Fired when a pointing device (usually a mouse) is pressed and released at the same point on the map.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only when the
* point that is pressed and released contains a visible portion of the specifed layer.
*
* @event click
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('click', function(e) {
* console.log('A click event has occurred at ' + e.lngLat);
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('click', 'poi-label', function(e) {
* console.log('A click event has occurred on a visible portion of the poi-label layer at ' + e.lngLat);
* });
* @see [Measure distances](https://www.mapbox.com/mapbox-gl-js/example/measure/)
* @see [Center the map on a clicked symbol](https://www.mapbox.com/mapbox-gl-js/example/center-on-symbol/)
*/
| 'click'
/**
* Fired when a pointing device (usually a mouse) is pressed and released twice at the same point on
* the map in rapid succession.
*
* **Note:** This event is compatible with the optional `layerId` parameter.
* If `layerId` is included as the second argument in {@link Map#on}, the event listener will fire only
* when the point that is clicked twice contains a visible portion of the specifed layer.
*
* @event dblclick
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('dblclick', function(e) {
* console.log('A dblclick event has occurred at ' + e.lngLat);
* });
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener for a specific layer
* map.on('dblclick', 'poi-label', function(e) {
* console.log('A dblclick event has occurred on a visible portion of the poi-label layer at ' + e.lngLat);
* });
*/
| 'dblclick'
/**
* Fired when a pointing device (usually a mouse) enters a visible portion of a specified layer from
* outside that layer or outside the map canvas.
*
* **Important:** This event can only be listened for when {@link Map#on} includes three arguments,
* where the second argument specifies the desired layer.
*
* @event mouseenter
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener
* map.on('mouseenter', 'water', function() {
* console.log('A mouseenter event occurred on a visible portion of the water layer.');
* });
* @see [Center the map on a clicked symbol](https://docs.mapbox.com/mapbox-gl-js/example/center-on-symbol/)
* @see [Display a popup on click](https://docs.mapbox.com/mapbox-gl-js/example/popup-on-click/)
*/
| 'mouseenter'
/**
* Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer, or leaves
* the map canvas.
*
* **Important:** This event can only be listened for when {@link Map#on} includes three arguements,
* where the second argument specifies the desired layer.
*
* @event mouseleave
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the pointing device leaves
* // a visible portion of the specified layer.
* map.on('mouseleave', 'water', function() {
* console.log('A mouseleave event occurred.');
* });
* @see [Highlight features under the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/hover-styles/)
* @see [Display a popup on click](https://docs.mapbox.com/mapbox-gl-js/example/popup-on-click/)
*/
| 'mouseleave'
/**
* Fired when a point device (usually a mouse) leaves the map's canvas.
*
* @event mouseout
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the pointing device leave's
* // the map's canvas.
* map.on('mouseout', function() {
* console.log('A mouseout event occurred.');
* });
*/
| 'mouseout'
/**
* Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.
*
* @event contextmenu
* @memberof Map
* @instance
* @property {MapMouseEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the right mouse button is
* // pressed within the map.
* map.on('contextmenu', function() {
* console.log('A contextmenu event occurred.');
* });
*/
| 'contextmenu'
/**
* Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.
*
* @event wheel
* @memberof Map
* @instance
* @property {MapWheelEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a wheel event occurs within the map.
* map.on('wheel', function() {
* console.log('A wheel event occurred.');
* });
*/
| 'wheel'
/**
* Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.
*
* @event touchstart
* @memberof Map
* @instance
* @property {MapTouchEvent} data
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a touchstart event occurs within the map.
* map.on('touchstart', function() {
* console.log('A touchstart event occurred.');
* });
* @see [Create a draggable point](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-point/)
*/
| 'touchstart'
/**
* Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.
*
* @event touchend
* @memberof Map
* @instance
* @property {MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a touchstart event occurs within the map.
* map.on('touchstart', function() {
* console.log('A touchstart event occurred.');
* });
* @see [Create a draggable point](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-point/)
*/
| 'touchend'
/**
* Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.
*
* @event touchmove
* @memberof Map
* @instance
* @property {MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a touchmove event occurs within the map.
* map.on('touchmove', function() {
* console.log('A touchmove event occurred.');
* });
* @see [Create a draggable point](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-point/)
*/
| 'touchmove'
/**
* Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.
*
* @event touchcancel
* @memberof Map
* @instance
* @property {MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a touchcancel event occurs within the map.
* map.on('touchcancel', function() {
* console.log('A touchcancel event occurred.');
* });
*/
| 'touchcancel'
/**
* Fired just before the map begins a transition from one
* view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.
*
* @event movestart
* @memberof Map
* @instance
* @property {{originalEvent: DragEvent}} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before the map begins a transition
* // from one view to another.
* map.on('movestart', function() {
* console.log('A movestart` event occurred.');
* });
*/
| 'movestart'
/**
* Fired repeatedly during an animated transition from one view to
* another, as the result of either user interaction or methods such as {@link Map#flyTo}.
*
* @event move
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // repeatedly during an animated transition.
* map.on('move', function() {
* console.log('A move event occurred.');
* });
* @see [Display HTML clusters with custom properties](https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/)
* @see [Filter features within map view](https://docs.mapbox.com/mapbox-gl-js/example/filter-features-within-map-view/)
*/
| 'move'
/**
* Fired just after the map completes a transition from one
* view to another, as the result of either user interaction or methods such as {@link Map#jumpTo}.
*
* @event moveend
* @memberof Map
* @instance
* @property {{originalEvent: DragEvent}} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after the map completes a transition.
* map.on('moveend', function() {
* console.log('A moveend event occurred.');
* });
* @see [Play map locations as a slideshow](https://www.mapbox.com/mapbox-gl-js/example/playback-locations/)
* @see [Filter features within map view](https://www.mapbox.com/mapbox-gl-js/example/filter-features-within-map-view/)
* @see [Display HTML clusters with custom properties](https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/)
*/
| 'moveend'
/**
* Fired when a "drag to pan" interaction starts. See {@link DragPanHandler}.
*
* @event dragstart
* @memberof Map
* @instance
* @property {{originalEvent: DragEvent}} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a "drag to pan" interaction starts.
* map.on('dragstart', function() {
* console.log('A dragstart event occurred.');
* });
*/
| 'dragstart'
/**
* Fired repeatedly during a "drag to pan" interaction. See {@link DragPanHandler}.
*
* @event drag
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // repeatedly during a "drag to pan" interaction.
* map.on('drag', function() {
* console.log('A drag event occurred.');
* });
*/
| 'drag'
/**
* Fired when a "drag to pan" interaction ends. See {@link DragPanHandler}.
*
* @event dragend
* @memberof Map
* @instance
* @property {{originalEvent: DragEvent}} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when a "drag to pan" interaction ends.
* map.on('dragend', function() {
* console.log('A dragend event occurred.');
* });
* @see [Create a draggable marker](https://docs.mapbox.com/mapbox-gl-js/example/drag-a-marker/)
*/
| 'dragend'
/**
* Fired just before the map begins a transition from one zoom level to another,
* as the result of either user interaction or methods such as {@link Map#flyTo}.
*
* @event zoomstart
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before a zoom transition starts.
* map.on('zoomstart', function() {
* console.log('A zoomstart event occurred.');
* });
*/
| 'zoomstart'
/**
* Fired repeatedly during an animated transition from one zoom level to another,
* as the result of either user interaction or methods such as {@link Map#flyTo}.
*
* @event zoom
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // repeatedly during a zoom transition.
* map.on('zoom', function() {
* console.log('A zoom event occurred.');
* });
* @see [Update a choropleth layer by zoom level](https://www.mapbox.com/mapbox-gl-js/example/updating-choropleth/)
*/
| 'zoom'
/**
* Fired just after the map completes a transition from one zoom level to another,
* as the result of either user interaction or methods such as {@link Map#flyTo}.
*
* @event zoomend
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after a zoom transition finishes.
* map.on('zoomend', function() {
* console.log('A zoomend event occurred.');
* });
*/
| 'zoomend'
/**
* Fired when a "drag to rotate" interaction starts. See {@link DragRotateHandler}.
*
* @event rotatestart
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before a "drag to rotate" interaction starts.
* map.on('rotatestart', function() {
* console.log('A rotatestart event occurred.');
* });
*/
| 'rotatestart'
/**
* Fired repeatedly during a "drag to rotate" interaction. See {@link DragRotateHandler}.
*
* @event rotate
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // repeatedly during "drag to rotate" interaction.
* map.on('rotate', function() {
* console.log('A rotate event occurred.');
* });
*/
| 'rotate'
/**
* Fired when a "drag to rotate" interaction ends. See {@link DragRotateHandler}.
*
* @event rotateend
* @memberof Map
* @instance
* @property {MapMouseEvent | MapTouchEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after a "drag to rotate" interaction ends.
* map.on('rotateend', function() {
* console.log('A rotateend event occurred.');
* });
*/
| 'rotateend'
/**
* Fired whenever the map's pitch (tilt) begins a change as
* the result of either user interaction or methods such as {@link Map#flyTo} .
*
* @event pitchstart
* @memberof Map
* @instance
* @property {MapEventData} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before a pitch (tilt) transition starts.
* map.on('pitchstart', function() {
* console.log('A pitchstart event occurred.');
* });
*/
| 'pitchstart'
/**
* Fired repeatedly during the map's pitch (tilt) animation between
* one state and another as the result of either user interaction
* or methods such as {@link Map#flyTo}.
*
* @event pitch
* @memberof Map
* @instance
* @property {MapEventData} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // repeatedly during a pitch (tilt) transition.
* map.on('pitch', function() {
* console.log('A pitch event occurred.');
* });
*/
| 'pitch'
/**
* Fired immediately after the map's pitch (tilt) finishes changing as
* the result of either user interaction or methods such as {@link Map#flyTo}.
*
* @event pitchend
* @memberof Map
* @instance
* @property {MapEventData} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after a pitch (tilt) transition ends.
* map.on('pitchend', function() {
* console.log('A pitchend event occurred.');
* });
*/
| 'pitchend'
/**
* Fired when a "box zoom" interaction starts. See {@link BoxZoomHandler}.
*
* @event boxzoomstart
* @memberof Map
* @instance
* @property {MapBoxZoomEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before a "box zoom" interaction starts.
* map.on('boxzoomstart', function() {
* console.log('A boxzoomstart event occurred.');
* });
*/
| 'boxzoomstart'
/**
* Fired when a "box zoom" interaction ends. See {@link BoxZoomHandler}.
*
* @event boxzoomend
* @memberof Map
* @instance
* @type {Object}
* @property {MapBoxZoomEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after a "box zoom" interaction ends.
* map.on('boxzoomend', function() {
* console.log('A boxzoomend event occurred.');
* });
*/
| 'boxzoomend'
/**
* Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold.
* See {@link BoxZoomHandler}.
*
* @event boxzoomcancel
* @memberof Map
* @instance
* @property {MapBoxZoomEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // the user cancels a "box zoom" interaction.
* map.on('boxzoomcancel', function() {
* console.log('A boxzoomcancel event occurred.');
* });
*/
| 'boxzoomcancel'
/**
* Fired immediately after the map has been resized.
*
* @event resize
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // immediately after the map has been resized.
* map.on('resize', function() {
* console.log('A resize event occurred.');
* });
*/
| 'resize'
/**
* Fired when the WebGL context is lost.
*
* @event webglcontextlost
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the WebGL context is lost.
* map.on('webglcontextlost', function() {
* console.log('A webglcontextlost event occurred.');
* });
*/
| 'webglcontextlost'
/**
* Fired when the WebGL context is restored.
*
* @event webglcontextrestored
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the WebGL context is restored.
* map.on('webglcontextrestored', function() {
* console.log('A webglcontextrestored event occurred.');
* });
*/
| 'webglcontextrestored'
/**
* Fired immediately after all necessary resources have been downloaded
* and the first visually complete rendering of the map has occurred.
*
* @event load
* @memberof Map
* @instance
* @type {Object}
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the map has finished loading.
* map.on('load', function() {
* console.log('A load event occurred.');
* });
* @see [Draw GeoJSON points](https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/)
* @see [Add live realtime data](https://www.mapbox.com/mapbox-gl-js/example/live-geojson/)
* @see [Animate a point](https://www.mapbox.com/mapbox-gl-js/example/animate-point-along-line/)
*/
| 'load'
/**
* Fired whenever the map is drawn to the screen, as the result of
*
* - a change to the map's position, zoom, pitch, or bearing
* - a change to the map's style
* - a change to a GeoJSON source
* - the loading of a vector tile, GeoJSON file, glyph, or sprite
*
* @event render
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // whenever the map is drawn to the screen.
* map.on('render', function() {
* console.log('A render event occurred.');
* });
*/
| 'render'
/**
* Fired after the last frame rendered before the map enters an
* "idle" state:
*
* - No camera transitions are in progress
* - All currently requested tiles have loaded
* - All fade/transition animations have completed
*
* @event idle
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just before the map enters an "idle" state.
* map.on('idle', function() {
* console.log('A idle event occurred.');
* });
*/
| 'idle'
/**
* Fired immediately after the map has been removed with {@link Map.event:remove}.
*
* @event remove
* @memberof Map
* @instance
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // just after the map is removed.
* map.on('remove', function() {
* console.log('A remove event occurred.');
* });
*/
| 'remove'
/**
* Fired when an error occurs. This is GL JS's primary error reporting
* mechanism. We use an event instead of `throw` to better accommodate
* asyncronous operations. If no listeners are bound to the `error` event, the
* error will be printed to the console.
*
* @event error
* @memberof Map
* @instance
* @property {{error: {message: string}}} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when an error occurs.
* map.on('error', function() {
* console.log('A error event occurred.');
* });
*/
| 'error'
/**
* Fired when any map data loads or changes. See {@link MapDataEvent}
* for more information.
*
* @event data
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when map data loads or changes.
* map.on('data', function() {
* console.log('A data event occurred.');
* });
* @see [Display HTML clusters with custom properties](https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/)
*/
| 'data'
/**
* Fired when the map's style loads or changes. See
* {@link MapDataEvent} for more information.
*
* @event styledata
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when the map's style loads or changes.
* map.on('styledata', function() {
* console.log('A styledata event occurred.');
* });
*/
| 'styledata'
/**
* Fired when one of the map's sources loads or changes, including if a tile belonging
* to a source loads or changes. See {@link MapDataEvent} for more information.
*
* @event sourcedata
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when one of the map's sources loads or changes.
* map.on('sourcedata', function() {
* console.log('A sourcedata event occurred.');
* });
*/
| 'sourcedata'
/**
* Fired when any map data (style, source, tile, etc) begins loading or
* changing asyncronously. All `dataloading` events are followed by a `data`
* or `error` event. See {@link MapDataEvent} for more information.
*
* @event dataloading
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // when any map data begins loading
* // or changing asynchronously.
* map.on('dataloading', function() {
* console.log('A dataloading event occurred.');
* });
*/
| 'dataloading'
/**
* Fired when the map's style begins loading or changing asyncronously.
* All `styledataloading` events are followed by a `styledata`
* or `error` event. See {@link MapDataEvent} for more information.
*
* @event styledataloading
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // map's style begins loading or
* // changing asyncronously.
* map.on('styledataloading', function() {
* console.log('A styledataloading event occurred.');
* });
*/
| 'styledataloading'
/**
* Fired when one of the map's sources begins loading or changing asyncronously.
* All `sourcedataloading` events are followed by a `sourcedata` or `error` event.
* See {@link MapDataEvent} for more information.
*
* @event sourcedataloading
* @memberof Map
* @instance
* @property {MapDataEvent} data
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // map's sources begin loading or
* // changing asyncronously.
* map.on('sourcedataloading', function() {
* console.log('A sourcedataloading event occurred.');
* });
*/
| 'sourcedataloading'
/**
* Fired when an icon or pattern needed by the style is missing. The missing image can
* be added with {@link Map#addImage} within this event listener callback to prevent the image from
* being skipped. This event can be used to dynamically generate icons and patterns.
*
* @event styleimagemissing
* @memberof Map
* @instance
* @property {string} id The id of the missing image.
* @example
* // Initialize the map
* var map = new mapboxgl.Map({ // map options });
* // Set an event listener that fires
* // an icon or pattern is missing.
* map.on('styleimagemissing', function() {
* console.log('A styleimagemissing event occurred.');
* });
* @see [Generate and add a missing icon to the map](https://mapbox.com/mapbox-gl-js/example/add-image-missing-generated/)
*/
| 'styleimagemissing'
/**
* @event style.load
* @memberof Map
* @instance
* @private
*/
| 'style.load';
|