The Map object represents the map on your page. It exposes methods and properties that enable you to programmatically change the map, and fires events as users interact with it.
You create a Map by specifying a container and other options. Then Flightmap JS initializes the map on the page and returns your Map object.
|options.container||String||The HTML element in which Flightmap JS will render the map, or the element's string id . The specified element must have no children.|
|options.minZoom||number(0)||The minimum zoom level of the map (0-24).|
|options.maxZoom||number(22)||The maximum zoom level of the map (0-24).|
|options.minPitch||number(0)||The minimum pitch of the map (0-60).|
|options.maxPitch||number(60)||The maximum pitch of the map (0-60).|
|options.style||Object | String||Style can be style-dark.json or style-bright.json|
|options.hash||boolean | String(false)||If true , the map's position (zoom, center latitude, center longitude, bearing, and pitch) will be synced with the hash fragment of the page's URL. For example, http://path/to/my/page.html#2.59/39.26/53.07/-24.1/60 . An additional string may optionally be provided to indicate a parameter-styled hash, e.g. http://path/to/my/page.html#map=2.59/39.26/53.07/-24.1/60&foo=bar , where foo is a custom parameter and bar is an arbitrary hash distinct from the map hash.|
|options.interactive||boolean(true)||If false , no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction.|
|options.bearingSnap||number(7)||The threshold, measured in degrees, that determines when the map's bearing will snap to north. For example, with a bearingSnap of 7, if the user rotates the map within 7 degrees of north, the map will automatically snap to exact north.|
|options.clickTolerance||number(3)||The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).|
|options.attributionControl||boolean(true)||If true , an AttributionControl will be added to the map.|
|options.customAttribution||String||String or strings to show in an AttributionControl . Only applicable if options.attributionControl is true .|
|options.failIfMajorPerformanceCaveat||boolean(false)||If true , map creation will fail if the performance of Flightmap JS would be dramatically worse than expected (i.e. a software renderer would be used).|
|options.preserveDrawingBuffer||boolean(false)||If true , the map's canvas can be exported to a PNG using map.getCanvas().toDataURL() . This is false by default as a performance optimization.|
|options.antialias||boolean||If true , the gl context will be created with MSAA antialiasing, which can be useful for antialiasing custom layers. this is false by default as a performance optimization.|
|options.refreshExpiredTiles||boolean(true)||If false , the map won't attempt to re-request tiles once they expire per their HTTP cacheControl / expires headers.|
|options.maxBounds||LngLatBounds||If set, the map will be constrained to the given bounds.|
|options.scrollZoom||(boolean | Object)(true)||If true , the "scroll to zoom" interaction is enabled. An Object value is passed as options to ScrollZoomHandler#enable .|
|options.boxZoom||boolean(true)||If true , the "box zoom" interaction is enabled.|
|options.dragRotate||boolean(true)||If true , the "drag to rotate" interaction is enabled|
|options.dragPan||(boolean | Object)(true)||If true , the "drag to pan" interaction is enabled. An Object value is passed as options to DragPanHandler#enable .|
|options.keyboard||boolean(true)||If true , keyboard shortcuts are enabled|
|options.doubleClickZoom||boolean(true)||If true , the "double click to zoom" interaction is enabled|
|options.touchZoomRotate||(boolean | Object)(true)||If true , the "pinch to rotate and zoom" interaction is enabled. An Object value is passed as options to TouchZoomRotateHandler#enable .|
|options.trackResize||boolean(true)||If true , the map will automatically resize when the browser window resizes.|
|options.center||LngLat([0,0])||The inital geographical centerpoint of the map. If center is not specified in the constructor options, Flightmap JS will look for it in the map's style object. If it is not specified in the style, either, it will default to [0, 0].|
Note : Flightmap uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.
|options.zoom||number(0)||The initial zoom level of the map. If zoom is not specified in the constructor options, Flightmap JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0 .|
|options.bearing||number(0)||The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. If bearing is not specified in the constructor options, Mapbox GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0 .|
|options.pitch||number(0)||The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-60). If pitch is not specified in the constructor options, Flightmap JS will look for it in the map's style object. If it is not specified in the style, either, it will default to 0 .|
|options.bounds||LngLatBounds||The initial bounds of the map. If bounds is specified, it overrides center and zoom constructor options.|
|options.fitBoundsOptions||boolean(true)||If true , multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to false :
|options.maxTileCacheSize||number(null)||The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport.|
|options.transformRequest||RequestTransformFunction(null)||A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the credentials property for cross-origin requests. Expected to return an object with a url property and optionally headers and credentials properties.|
|options.fadeDuration||number(300)||Controls the duration of the fade-in/fade-out animation for label collisions, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.|
|options.crossSourceCollisions||boolean(true)||If true , symbols from multiple sources can collide with each other during collision detection. If false , collision detection is run separately for the symbols in each source.|
|options.accessToken||String(null)||If specified, map will use this token instead of the one defined in mapboxgl.accessToken.|
|options.locale||string(null)||A patch to apply to the default localization table for UI strings, e.g. control tooltips. The locale object maps namespaced UI string IDs to translated strings in the target language; see src/ui/default_locale.js for an example with all supported string IDs. The object may specify all UI strings (thereby adding support for a new translation) or only a subset of strings (thereby patching the default translation table).|
Gets and sets the number of web workers instantiated on a page with GL JS maps. By default, it is set to half the number of CPU cores (capped at 6). Make sure to set this property before creating any map instances for it to have effect.
mapboxgl.workerCount = 2;
Gets and sets the maximum number of images (raster tiles, sprites, icons) to load in parallel, which affects performance in raster-heavy maps. 16 by default.
mapboxgl.maxParallelImageRequests = 10;
Options common to map movement methods that involve animation, such as Map panBy and Map easeTo, controlling the duration and easing function of the animation. All properties are optional.
|duration||number||The animation's duration, measured in milliseconds.|
|easing||Function||A function taking a time in the range 0..1 and returning a number where 0 is the initial state and 1 is the final state.|
|offset||Array of two points in pixel||of the target center relative to real map container center at the end of animation.|
|animate||boolean||If false , no animation will occur.|
|essential||boolean||If true , then the animation is considered essential and will not be affected by prefers-reduced-motion .|
Options common to Map jumpTo, Map easeTo, and Map flyTo, controlling the desired location, zoom, bearing, and pitch of the camera. All properties are optional, and when a property is omitted, the current camera value for that property will remain unchanged.
|center||LngLat||The desired center.|
|zoom||number||The desired zoom level.|
|bearing||number||The desired bearing, in degrees. The bearing is the compass direction that is "up"; for example, a bearing of 90° orients the map so that east is up.|
|pitch||number||The desired pitch, in degrees.|
|around||LngLat||If zoom is specified, around determines the point around which the zoom is centered.|
Options for setting padding on a call to Map fitBounds. All properties of this object must be non-negative integers.
top (number) : Padding in pixels from the top of the map canvas.
bottom (number) : Padding in pixels from the bottom of the map canvas.
left (number) : Padding in pixels from the left of the map canvas.
right (number) : Padding in pixels from the right of the map canvas.
A RequestParameters object to be returned from Map.options.transformRequest callbacks.
url (string) : The URL to be requested.
headers (object) : The headers to be sent with the request.
credentials (string) : 'same-origin'|'include' Use 'include' to send cookies with cross-origin requests.
Hurry up! This offer is only available till 31st October!