WEB GL JS

웹 개발, 어플리케이션에서 활용될 수 있도록 Javascript로 제공되는 지도 플랫폼 입니다.

routogl.Map

Description

Map object represents the map on your page (Example:)


Constructor

new routogl.Map(routoMapOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // 지도 컨테이너 ID
  style: routogl.RoutoStyle.LIGHT, // 지도 스타일
  center: [127.0586339, 37.507009], // 초기 지도 위치 [lng, lat]
  zoom: 17, // 초기 줌 레벨
});

Parameters

Name {Type} Description
routoMapOption { Object } routo Map Options.
Properties
Name {Type} Description
container { string } The HTML element in which Mapbox GL JS will render the map, or the element's string id . The specified element must have no children. default value: 'map'
styleId { string|routogl/RoutoStyle } The map's Routo style. routogl.RoutoStyle.LIGHT, routogl.RoutoStyle.DARK default value: ['routo://styles/routo/light', routogl.RoutoStyle.LIGHT]
center { Array.<number> } The initial geographical centerpoint of the map. ([lon, lat]) default value: [127.0586339, 37.507009]
zoom { number } The initial zoom level of the map. default value: 17
antialias { boolean } If true , the gl context will be created with antialiasing. default value: false
attributionControl { boolean } If true , an AttributionControl will be added to the map. default value: true
bearing { number } The initial bearing (rotation) of the map, measured in degrees counter-clockwise from north. default value: 0
bearingSnap { number } The threshold, measured in degrees, that determines when the map's bearing will snap to north. default value: 7
bounds { LngLatBounds } The initial bounds of the map. default value: null
boxZoom { boolean } If true , the "box zoom" interaction is enabled default value: true
clickTolerance { number } The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click default value: 3
collectResourceTiming { boolean } If true , Resource Timing API information will be collected for requests made by GeoJSON and Vector Tile web workers default value: false
cooperativeGestures { number } If true , scroll zoom will require pressing the ctrl or ⌘ key while scrolling to zoom map, and touch pan will require using two fingers while panning to move the map. default value: null
crossSourceCollisions { boolean } If true , symbols from multiple sources can collide with each other during collision detection. default value: true
doubleClickZoom { boolean } If true , the "double click to zoom" interaction is enabled default value: true
dragPan { boolean } If true , the "drag to pan" interaction is enabled. default value: true
dragRotate { boolean } If true , the "drag to rotate" interaction is enabled default value: true
fadeDuration { number } Controls the duration of the fade-in/fade-out animation for label collisions, in milliseconds. default value: 300
fitBoundsOptions { number } A Map#fitBounds options object to use only when fitting the initial bounds provided above. default value: null
hash { object } 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. default value: false
interactive { boolean } If false , no mouse, touch, or keyboard listeners will be attached to the map, so it will not respond to interaction. default value: true
keyboard { boolean } If true , keyboard shortcuts are enabled default value: true
language { string } A string with a BCP 47 language tag, or an array of such strings representing the desired languages used for the map's labels and UI components. default value: null
locale { object } A patch to apply to the default localization table for UI strings such as control tooltips. default value: null
localFontFamily { string } Defines a CSS font-family for locally overriding generation of all glyphs. default value: null
localIdeographFontFamily { string } Defines a CSS font-family for locally overriding generation of glyphs in the 'CJK Unified Ideographs', 'Hiragana', 'Katakana', 'Hangul Syllables' and 'CJK Symbols and Punctuation' ranges. default value: 'sans-serif'
maxBounds { LngLatBounds } If set, the map will be constrained to the given bounds. default value: null
maxPitch { number } The maximum pitch of the map (0-85). default value: 85
maxTileCacheSize { number } The maximum number of tiles stored in the tile cache for a given source. default value: null
maxZoom { number } The maximum zoom level of the map (0-26). default value: 22
minPitch { number } The minimum pitch of the map (0-85). default value: 0
minTileCacheSize { number } The minimum number of tiles stored in the tile cache for a given source. default value: null
minZoom { number } The minimum zoom level of the map (0-24). default value: 0
pitch { number } The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-85). default value: 0
pitchWithRotate { boolean } If false , the map's pitch (tilt) control with "drag to rotate" interaction will be disabled. default value: true
preserveDrawingBuffer { boolean } If true , the map's canvas can be exported to a PNG using map.getCanvas().toDataURL() . default value: false
projection { string } The projection the map should be rendered in. (albers, equalEarth, equirectangluar, lambertConformalConic, mercator, naturalEarth, winkelTripel) default value: 'mercator'
refreshExpiredTiles { boolean } If false , the map won't attempt to re-request tiles once they expire per their HTTP cacheControl / expires headers. default value: true
renderWorldCopies { boolean } If true , multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. default value: true
respectPrefersReducedMotion { boolean } If set to true , the map will respect the user's prefers-reduced-motion browser setting and apply a reduced motion mode, minimizing animations and transitions. default value: true
scrollZoom { boolean } If true , the "scroll to zoom" interaction is enabled. default value: true
touchPitch { boolean } If true , the "drag to pitch" interaction is enabled. default value: true
touchZoomRotate { boolean } If true , the "pinch to rotate and zoom" interaction is enabled. default value: true
trackResize { boolean } If true , the map will automatically resize when the browser window resizes. default value: true
worldview { string } Sets the map's worldview. default value: null

Extends


Methods

addControl(control, position, opt) → {Map}

Descript

Adds an IControl to the map, calling `control.onAdd(this)`.

Example

// Add zoom and rotation controls to the map.
map.addControl(new routogl.NavigationControl());

Parameters

Name {Type} Description
control { IControl } The IControl to add.
position { string } Position on the map to which the control will be added. Valid values are `'top-left'`, `'top'`, `'top-right'`, `'right'`, `'bottom-right'`, `'bottom'`, `'bottom-left'`, and `'left'`. Defaults to `'top-right'`.

Returns

Returns itself to allow for method chaining.

Type
Map
addSource(id, source) → {Map}

Descript

Adds a source to the map's style.

Examples

map.addSource('my-data', {
    type: 'vector',
    url: 'mapbox://myusername.tilesetid'
});
map.addSource('my-data', {
    "type": "geojson",
    "data": {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-77.0323, 38.9131]
        },
        "properties": {
            "title": "Mapbox DC",
            "marker-symbol": "monument"
        }
    }
});

Parameters

Name {Type} Description
id { string } The ID of the source to add. Must not conflict with existing sources.
source { Object } The source object

Returns

Returns itself to allow for method chaining.

Type
Map
areTilesLoaded() → {boolean}

Descript

Returns a Boolean indicating whether all tiles in the viewport from all sources on the style are loaded.

Example

const tilesLoaded = map.areTilesLoaded();

Returns

A Boolean indicating whether all tiles are loaded.

Type
boolean
frameReady() → {boolean}

Descript

Returns a Boolean indicating whether the map is finished rendering, meaning all animations are finished.

Example

const frameReady = map.frameReady();

Returns

A Boolean indicating whether map finished rendering.

Type
boolean
getBounds() → {LngLatBounds}

Descript

Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region. If a padding is set on the map, the bounds returned are for the inset. With globe projection, the smallest bounds encompassing the visible region may not precisely represent the visible region due to the earth's curvature.

Example

const bounds = map.getBounds();

Returns

The geographical bounds of the map as LngLatBounds.

Type
LngLatBounds
getCanvas() → {HTMLCanvasElement}

Descript

Returns the map's `canvas` element.

Example

const canvas = map.getCanvas();

Returns

The map's `canvas` element.

Type
HTMLCanvasElement
getCanvasContainer() → {HTMLElement}

Descript

Returns the HTML element containing the map's `canvas` element. If you want to add non-GL overlays to the map, you should append them to this element. This is the element to which event bindings for map interactivity (such as panning and zooming) are attached. It will receive bubbled events from child elements such as the `canvas`, but not from map controls.

Example

const canvasContainer = map.getCanvasContainer();

Returns

The container of the map's `canvas`.

Type
HTMLElement
getContainer() → {HTMLElement}

Descript

Returns the map's containing HTML element.

Example

const container = map.getContainer();

Returns

The map's container.

Type
HTMLElement
getMaxBounds() → {Map}

Descript

Returns the maximum geographical bounds the map is constrained to, or `null` if none set.

Example

const maxBounds = map.getMaxBounds();

Returns

The map object.

Type
Map
getMaxPitch() → {number}

Descript

Returns the map's maximum allowable pitch.

Example

const maxPitch = map.getMaxPitch();

Returns

Returns `maxPitch`.

Type
number
getMaxZoom() → {number}

Descript

Returns the map's maximum allowable zoom level.

Example

const maxZoom = map.getMaxZoom();

Returns

Returns `maxZoom`.

Type
number
getMinPitch() → {number}

Descript

Returns the map's minimum allowable pitch.

Example

const minPitch = map.getMinPitch();

Returns

Returns `minPitch`.

Type
number
getMinZoom() → {number}

Descript

Returns the map's minimum allowable zoom level.

Example

const minZoom = map.getMinZoom();

Returns

Returns `minZoom`.

Type
number
getProjection() → {ProjectionSpecification}

Descript

Returns a [projection](https://docs.mapbox.com/mapbox-gl-js/style-spec/projection/) object that defines the current map projection.

Example

const projection = map.getProjection();

Returns

The [projection](https://docs.mapbox.com/mapbox-gl-js/style-spec/projection/) defining the current map projection.

Type
ProjectionSpecification
getRain() → {RainSpecification}

Descript

Returns the rain specification or `null` if rain is not set on the map. *This API is experimental, not production ready and subject to change in future versions*.

Example

const rain = map.getRain();

Returns

Rain specification properties of the style.

Type
RainSpecification
getRenderWorldCopies() → {boolean}

Descript

Returns the state of `renderWorldCopies`. If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude. - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level.

Example

const worldCopiesRendered = map.getRenderWorldCopies();

Returns

Returns `renderWorldCopies` boolean.

Type
boolean
getSnow() → {SnowSpecification}

Descript

Returns the snow specification or `null` if snow is not set on the map. *This API is experimental, not production ready and subject to change in future versions*.

Example

const snow = map.getSnow();

Returns

Snow specification properties of the style.

Type
SnowSpecification
getSource(id) → (nullable) {Object}

Descript

Returns the source with the specified ID in the map's style. This method is often used to update a source using the instance members for the relevant source type as defined in [Sources](#sources). For example, setting the `data` for a GeoJSON source or updating the `url` and `coordinates` of an image source.

Example

const sourceObject = map.getSource('points');

Parameters

Name {Type} Description
id { string } The ID of the source to get.

Returns

The style source with the specified ID or `undefined` if the ID corresponds to no existing sources. The shape of the object varies by source type. A list of options for each source type is available on the Mapbox Style Specification's [Sources](https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/) page.

Type
Object
getStyle() → {Object}

Descript

Returns the map's Mapbox [style](https://docs.mapbox.com/help/glossary/style/) object, a JSON object which can be used to recreate the map's style. For the Mapbox Standard style or any "fragment" style (which is a style with `fragment: true` or a `schema` property defined), this method returns an empty style with no layers or sources. The original style is wrapped into an import with the ID `basemap` as a fragment style and is not intended to be used directly. This design ensures that user logic is not tied to style internals, allowing Mapbox to roll out style updates seamlessly and consistently.

Example

map.on('load', () => {
    const styleJson = map.getStyle();
});

Returns

The map's style JSON object.

Type
Object
getVersion() → {string}

Descript

버전 확인

Example

const version = map.getVersion();

Returns

버전

Type
string
hasControl(control) → {boolean}

Descript

Checks if a control is on the map.

Example

// Define a new navigation control.
const navigation = new routogl.NavigationControl();
// Add zoom and rotation controls to the map.
map.addControl(navigation);
// Check that the navigation control exists on the map.
const added = map.hasControl(navigation);
// added === true

Parameters

Name {Type} Description
control { IControl } The IControl to check.

Returns

True if map contains control.

Type
boolean
hideLayer(layerId)

Descript

hide layer.

Parameters

Name {Type} Description
layerId { string } layer id
isMoving() → {boolean}

Descript

Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.

Example

const isMoving = map.isMoving();

Returns

True if the map is moving.

Type
boolean
isPointOnSurface(point) → {boolean}

Descript

Determines if the given point is located on a visible map surface.

Example

const pointOnSurface = map.isPointOnSurface([100, 200]);

Parameters

Name {Type} Description
point { PointLike } The point to be checked, specified as an array of two numbers representing the x and y coordinates, or as a Point object.

Returns

Returns `true` if the point is on the visible map surface, otherwise returns `false`.

Type
boolean
isRotating() → {boolean}

Descript

Returns true if the map is rotating due to a camera animation or user gesture.

Example

map.isRotating();

Returns

True if the map is rotating.

Type
boolean
isSourceLoaded(id) → {boolean}

Descript

Returns a Boolean indicating whether the source is loaded. Returns `true` if the source with the given ID in the map's style has no outstanding network requests, otherwise `false`.

Example

const sourceLoaded = map.isSourceLoaded('bathymetry-data');

Parameters

Name {Type} Description
id { string } The ID of the source to be checked.

Returns

A Boolean indicating whether the source is loaded.

Type
boolean
isStyleLoaded() → {boolean}

Descript

Returns a Boolean indicating whether the map's style is fully loaded.

Example

const styleLoadStatus = map.isStyleLoaded();

Returns

A Boolean indicating whether the style is fully loaded.

Type
boolean
isZooming() → {boolean}

Descript

Returns true if the map is zooming due to a camera animation or user gesture.

Example

const isZooming = map.isZooming();

Returns

True if the map is zooming.

Type
boolean
loaded() → {boolean}

Descript

Returns a Boolean indicating whether the map is fully loaded. Returns `false` if the style is not yet fully loaded, or if there has been a change to the sources or style that has not yet fully loaded.

Example

const isLoaded = map.loaded();

Returns

A Boolean indicating whether the map is fully loaded.

Type
boolean
off(eventName, layer, callback)

Descript

remove event

Parameters

Name {Type} Description
eventName { string } event name (click, moveend ...)
layer { string } layer id
callback { function } callback
on(eventName, layer, callback)

Descript

register event

Parameters

Name {Type} Description
eventName { string } event name (click, moveend ...)
layer { string } layer id
callback { function } callback
project(lnglat) → {Point}

Descript

Returns a Point representing pixel coordinates, relative to the map's `container`, that correspond to the specified geographical location. When the map is pitched and `lnglat` is completely behind the camera, there are no pixel coordinates corresponding to that location. In that case, the `x` and `y` components of the returned Point are set to Number.MAX_VALUE.

Example

const coordinate = [-122.420679, 37.772537];
const point = map.project(coordinate);

Parameters

Name {Type} Description
lnglat { LngLatLike } The geographical location to project.

Returns

The Point corresponding to `lnglat`, relative to the map's `container`.

Type
Point
queryRenderedFeatures(geometry, opt, options, opt) → {Array.<Object>}

Descript

Returns an array of [GeoJSON](http://geojson.org/) [Feature objects](https://tools.ietf.org/html/rfc7946#section-3.2) representing visible features that satisfy the query parameters.

Examples

// Find all features at a point
const features = map.queryRenderedFeatures(
  [20, 35],
  {layers: ['my-layer-name']}
);
// Find all features within a static bounding box
const features = map.queryRenderedFeatures(
  [[10, 20], [30, 50]],
  {layers: ['my-layer-name']}
);
// Find all features within a bounding box around a point
const width = 10;
const height = 20;
const features = map.queryRenderedFeatures([
    [point.x - width / 2, point.y - height / 2],
    [point.x + width / 2, point.y + height / 2]
], {layers: ['my-layer-name']});
// Query all rendered features from a single layer

Parameters

Name {Type} Description
geometry { PointLike|Array.<PointLike> } The geometry of the query region in pixels: either a single point or bottom left and top right points describing a bounding box, where the origin is at the top left. Omitting this parameter (by calling Map#queryRenderedFeatures with zero arguments, or with only an `options` argument) is equivalent to passing a bounding box encompassing the entire map viewport. Only values within the existing viewport are supported.
options { Object } Options object.
Properties
Name {Type} Description
layers { Array.<string> } An array of [style layer IDs](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layer-id) for the query to inspect. Only features within these layers will be returned. If this parameter is undefined, all layers will be checked.
filter { Array } A [filter](https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#filter) to limit query results.
validate { boolean } Whether to check if the [options.filter] conforms to the Mapbox GL Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. default value: true

Returns

An array of [GeoJSON](http://geojson.org/) [feature objects](https://tools.ietf.org/html/rfc7946#section-3.2). The `properties` value of each returned feature object contains the properties of its source feature. For GeoJSON sources, only string and numeric property values are supported. `null`, `Array`, and `Object` values are not supported. Each feature includes top-level `layer`, `source`, and `sourceLayer` properties. The `layer` property is an object representing the style layer to which the feature belongs. Layout and paint properties in this object contain values which are fully evaluated for the given zoom level and feature. Only features that are currently rendered are included. Some features will **not** be included, like: - Features from layers whose `visibility` property is `"none"`. - Features from layers whose zoom range excludes the current zoom level. - Symbol features that have been hidden due to text or icon collision. Features from all other layers are included, including features that may have no visible contribution to the rendered result; for example, because the layer's opacity or color alpha component is set to 0. The topmost rendered feature appears first in the returned array, and subsequent features are sorted by descending z-order. Features that are rendered multiple times (due to wrapping across the antimeridian at low zoom levels) are returned only once (though subject to the following caveat). Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.

Type
Array.<Object>
querySourceFeatures(sourceId, parameters, opt) → {Array.<Object>}

Descript

Returns an array of [GeoJSON](http://geojson.org/) [Feature objects](https://tools.ietf.org/html/rfc7946#section-3.2) representing features within the specified vector tile or GeoJSON source that satisfy the query parameters.

Example

// Find all features in one source layer in a vector source
const features = map.querySourceFeatures('your-source-id', {
    sourceLayer: 'your-source-layer'
});

Parameters

Name {Type} Description
sourceId { string } The ID of the vector tile or GeoJSON source to query.
parameters { Object } Options object.
Properties
Name {Type} Description
sourceLayer { string } The name of the [source layer](https://docs.mapbox.com/help/glossary/source-layer/) to query. *For vector tile sources, this parameter is required.* For GeoJSON sources, it is ignored.
filter { Array } A [filter](https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#filter) to limit query results.
validate { boolean } Whether to check if the [parameters.filter] conforms to the Mapbox GL Style Specification. Disabling validation is a performance optimization that should only be used if you have previously validated the values you will be passing to this function. default value: true

Returns

An array of [GeoJSON](http://geojson.org/) [Feature objects](https://tools.ietf.org/html/rfc7946#section-3.2). In contrast to Map#queryRenderedFeatures, this function returns all features matching the query parameters, whether or not they are rendered by the current style (in other words, are visible). The domain of the query includes all currently-loaded vector tiles and GeoJSON source tiles function does not check tiles outside the currently visible viewport. Because features come from tiled vector data or GeoJSON data that is converted to tiles internally, feature geometries may be split or duplicated across tile boundaries and, as a result, features may appear multiple times in query results. For example, suppose there is a highway running through the bounding rectangle of a query. The results of the query will be those parts of the highway that lie within the map tiles covering the bounding rectangle, even if the highway extends into other tiles, and the portion of the highway within each map tile will be returned as a separate feature. Similarly, a point feature near a tile boundary may appear in multiple tiles due to tile buffering.

Type
Array.<Object>
removeControl(control) → {Map}

Descript

Removes the control from the map.

Example

// Define a new navigation control.
const navigation = new routogl.NavigationControl();
// Add zoom and rotation controls to the map.
map.addControl(navigation);
// Remove zoom and rotation controls from the map.
map.removeControl(navigation);

Parameters

Name {Type} Description
control { IControl } The IControl to remove.

Returns

Returns itself to allow for method chaining.

Type
Map
removeSource(id) → {Map}

Descript

Removes a source from the map's style.

Example

map.removeSource('bathymetry-data');

Parameters

Name {Type} Description
id { string } The ID of the source to remove.

Returns

Returns itself to allow for method chaining.

Type
Map
resize(eventData) → {Map}

Descript

Resizes the map according to the dimensions of its `container` element. Checks if the map container size changed and updates the map if it has changed. This method must be called after the map's `container` is resized programmatically or when the map is shown after being initially hidden with CSS.

Example

// Resize the map when the map container is shown
// after being initially hidden with CSS.
const mapDiv = document.getElementById('map');
if (mapDiv.style.visibility === true) map.resize();

Parameters

Name {Type} Description
eventData { Object|null } Additional properties to be passed to `movestart`, `move`, `resize`, and `moveend` events that get triggered as a result of resize. This can be useful for differentiating the source of an event (for example, user-initiated or programmatically-triggered events).

Returns

Returns itself to allow for method chaining.

Type
Map
setAttributionControlPosition(position, opt)

Descript

set Attribution Control Position

Parameters

Name {Type} Description
position { string } position. default value: 'bottom-right'
setMap3dModelLayer(isVisible)

Descript

set 3d Model layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMapExtrusionLayer(isVisible)

Descript

set extrusion layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMapHDMapLayer(isVisible)

Descript

set hd map layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMapHillshadeLayer(isVisible)

Descript

set hillshade layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMapLanduseLayer(isVisible)

Descript

set landuse layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMapTrafficLayer(isVisible)

Descript

set traffic layer

Parameters

Name {Type} Description
isVisible { boolean } is visible.
setMaxBounds(bounds) → {Map}

Descript

Sets or clears the map's geographical bounds. Pan and zoom operations are constrained within these bounds. If a pan or zoom is performed that would display regions outside these bounds, the map will instead display a position and zoom level as close as possible to the operation's request while still remaining within the bounds. For `mercator` projection, the viewport will be constrained to the bounds. For other projections such as `globe`, only the map center will be constrained.

Example

// Define bounds that conform to the `LngLatBoundsLike` object.
const bounds = [
    [-74.04728, 40.68392], // [west, south]
    [-73.91058, 40.87764]  // [east, north]
];
// Set the map's max bounds.
map.setMaxBounds(bounds);

Parameters

Name {Type} Description
bounds { LngLatBoundsLike|null|undefined } The maximum bounds to set. If `null` or `undefined` is provided, the function removes the map's maximum bounds.

Returns

Returns itself to allow for method chaining.

Type
Map
setMaxPitch(maxPitch) → {Map}

Descript

Sets or clears the map's maximum pitch. If the map's current pitch is higher than the new maximum, the map will pitch to the new maximum.

Example

map.setMaxPitch(70);

Parameters

Name {Type} Description
maxPitch { number|null|undefined } The maximum pitch to set. If `null` or `undefined` is provided, the function removes the current maximum pitch (sets it to 85).

Returns

Returns itself to allow for method chaining.

Type
Map
setMaxZoom(maxZoom) → {Map}

Descript

Sets or clears the map's maximum zoom level. If the map's current zoom level is higher than the new maximum, the map will zoom to the new maximum.

Example

map.setMaxZoom(18.75);

Parameters

Name {Type} Description
maxZoom { number|null|undefined } The maximum zoom level to set. If `null` or `undefined` is provided, the function removes the current maximum zoom (sets it to 22).

Returns

Returns itself to allow for method chaining.

Type
Map
setMinPitch(minPitch) → {Map}

Descript

Sets or clears the map's minimum pitch. If the map's current pitch is lower than the new minimum, the map will pitch to the new minimum.

Example

map.setMinPitch(5);

Parameters

Name {Type} Description
minPitch { number|null|undefined } The minimum pitch to set (0-85). If `null` or `undefined` is provided, the function removes the current minimum pitch and resets it to 0.

Returns

Returns itself to allow for method chaining.

Type
Map
setMinZoom(minZoom) → {Map}

Descript

Sets or clears the map's minimum zoom level. If the map's current zoom level is lower than the new minimum, the map will zoom to the new minimum. It is not always possible to zoom out and reach the set `minZoom`. Other factors such as map height may restrict zooming. For example, if the map is 512px tall it will not be possible to zoom below zoom 0 no matter what the `minZoom` is set to.

Example

map.setMinZoom(12.25);

Parameters

Name {Type} Description
minZoom { number|null|undefined } The minimum zoom level to set (-2 - 24). If `null` or `undefined` is provided, the function removes the current minimum zoom and it will be reset to -2.

Returns

Returns itself to allow for method chaining.

Type
Map
setProjection(projection) → {Map}

Descript

Sets the map's projection. If called with `null` or `undefined`, the map will reset to Mercator.

Example

map.setProjection('albers');
map.setProjection({
    name: 'albers',
    center: [35, 55],
    parallels: [20, 60]
});

Parameters

Name {Type} Description
projection { ProjectionSpecification|string|null|undefined } The projection that the map should be rendered in. This can be a [projection](https://docs.mapbox.com/mapbox-gl-js/style-spec/projection/) object or a string of the projection's name.

Returns

Returns itself to allow for method chaining.

Type
Map
setRain(rain) → {Map}

Descript

Sets the rain property of the style. *This API is experimental, not production ready and subject to change in future versions*.

Example

map.setRain({
      density: 1,
      intensity: 0.3,
      "distortion-strength": 0.3
  });

Parameters

Name {Type} Description
rain { RainSpecification } The rain properties to set. If `null` or `undefined` is provided, this function call removes the rain from the map.

Returns

Returns itself to allow for method chaining.

Type
Map
setRenderWorldCopies(renderWorldCopies) → {Map}

Descript

Sets the state of `renderWorldCopies`.

Example

map.setRenderWorldCopies(true);

Parameters

Name {Type} Description
renderWorldCopies { boolean } If `true`, multiple copies of the world will be rendered side by side beyond -180 and 180 degrees longitude. If set to `false`: - When the map is zoomed out far enough that a single representation of the world does not fill the map's entire container, there will be blank space beyond 180 and -180 degrees longitude. - Features that cross 180 and -180 degrees longitude will be cut in two (with one portion on the right edge of the map and the other on the left edge of the map) at every zoom level. `undefined` is treated as `true`, `null` is treated as `false`.

Returns

Returns itself to allow for method chaining.

Type
Map
setSnow(snow) → {Map}

Descript

Sets the snow property of the style. *This API is experimental, not production ready and subject to change in future versions*.

Example

map.setSnow({
      density: 1,
      intensity: 0.3
  });

Parameters

Name {Type} Description
snow { SnowSpecification } The snow properties to set. If `null` or `undefined` is provided, this function call removes the snow from the map.

Returns

Returns itself to allow for method chaining.

Type
Map
setStyle(styleId, opt)

Descript

Updates the map's routo style object with a new value.

Parameters

Name {Type} Description
styleId { string|routogl/RoutoStyle } style. default value: ['routo://styles/routo/light', routogl.RoutoStyle.LIGHT]
showLayer(layerId)

Descript

show layer.

Parameters

Name {Type} Description
layerId { string } layer id
showTraffic(visible, opt)

Descript

show traffic layer.

Parameters

Name {Type} Description
visible { boolean } If true, show traffic layer. default value: true
unproject(point) → {LngLat}

Descript

Returns a LngLat representing geographical coordinates that correspond to the specified pixel coordinates. If horizon is visible, and specified pixel is above horizon, returns a LngLat corresponding to point on horizon, nearest to the point.

Example

map.on('click', (e) => {
    // When the map is clicked, get the geographic coordinate.
    const coordinate = map.unproject(e.point);
});

Parameters

Name {Type} Description
point { PointLike } The pixel coordinates to unproject.

Returns

The LngLat corresponding to `point`.

Type
LngLat

Events

boxzoomcancel

Descript

Fired when the user cancels a "box zoom" interaction, or when the bounding box does not meet the minimum size threshold. See BoxZoomHandler.

Type

  • MapBoxZoomEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// the user cancels a "box zoom" interaction.
map.on('boxzoomcancel', () => {
    console.log('A boxzoomcancel event occurred.');
});
boxzoomend

Descript

Fired when a "box zoom" interaction ends. See BoxZoomHandler.

Type

  • MapBoxZoomEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after a "box zoom" interaction ends.
map.on('boxzoomend', () => {
    console.log('A boxzoomend event occurred.');
});
boxzoomstart

Descript

Fired when a "box zoom" interaction starts. See BoxZoomHandler.

Type

  • MapBoxZoomEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just before a "box zoom" interaction starts.
map.on('boxzoomstart', () => {
    console.log('A boxzoomstart event occurred.');
});
click

Descript

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 Map#on, the event listener will fire only when the point that is pressed and released contains a visible portion of the specifed layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('click', (e) => {
    console.log(`A click event has occurred at ${e.lngLat}`);
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('click', 'poi-label', (e) => {
    console.log(`A click event has occurred on a visible portion of the poi-label layer at ${e.lngLat}`);
});
contextmenu

Descript

Fired when the right button of the mouse is clicked or the context menu key is pressed within the map.

Type

  • MapMouseEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the right mouse button is
// pressed within the map.
map.on('contextmenu', () => {
    console.log('A contextmenu event occurred.');
});
data

Descript

Fired when any map data loads or changes. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when map data loads or changes.
map.on('data', () => {
    console.log('A data event occurred.');
});
dataloading

Descript

Fired when any map data (style, source, tile, etc) begins loading or changing asynchronously. All `dataloading` events are followed by a `data` or `error` event. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when any map data begins loading
// or changing asynchronously.
map.on('dataloading', () => {
    console.log('A dataloading event occurred.');
});
dblclick

Descript

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 Map#on, the event listener will fire only when the point that is clicked twice contains a visible portion of the specifed layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('dblclick', (e) => {
    console.log(`A dblclick event has occurred at ${e.lngLat}`);
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('dblclick', 'poi-label', (e) => {
    console.log(`A dblclick event has occurred on a visible portion of the poi-label layer at ${e.lngLat}`);
});
drag

Descript

Fired repeatedly during a "drag to pan" interaction. See DragPanHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// repeatedly during a "drag to pan" interaction.
map.on('drag', () => {
    console.log('A drag event occurred.');
});
dragend

Descript

Fired when a "drag to pan" interaction ends. See DragPanHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when a "drag to pan" interaction ends.
map.on('dragend', () => {
    console.log('A dragend event occurred.');
});
dragstart

Descript

Fired when a "drag to pan" interaction starts. See DragPanHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when a "drag to pan" interaction starts.
map.on('dragstart', () => {
    console.log('A dragstart event occurred.');
});
error

Properties

Name Type Description
message string Error message.

Descript

Fired when an error occurs. This is Mapbox 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.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when an error occurs.
map.on('error', () => {
    console.log('A error event occurred.');
});
idle

Descript

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.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just before the map enters an "idle" state.
map.on('idle', () => {
    console.log('A idle event occurred.');
});
load

Descript

Fired immediately after all necessary resources have been downloaded and the first visually complete rendering of the map has occurred.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the map has finished loading.
map.on('load', () => {
    console.log('A load event occurred.');
});
mousedown

Descript

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 Map#on, the event listener will fire only when the the cursor is pressed while inside a visible portion of the specifed layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('mousedown', () => {
    console.log('A mousedown event has occurred.');
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('mousedown', 'poi-label', () => {
    console.log('A mousedown event has occurred on a visible portion of the poi-label layer.');
});
mouseenter

Descript

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 Map#on includes three arguments, where the second argument specifies the desired layer.

Type

  • MapMouseEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('mouseenter', 'water', () => {
    console.log('A mouseenter event occurred on a visible portion of the water layer.');
});
mouseleave

Descript

Fired when a pointing device (usually a mouse) leaves a visible portion of a specified layer or moves from the specified layer to outside the map canvas. **Note:** To detect when the mouse leaves the canvas, independent of layer, use Map.event:mouseout instead. **Important:** This event can only be listened for when Map#on includes three arguments, where the second argument specifies the desired layer.

Type

  • MapMouseEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the pointing device leaves
// a visible portion of the specified layer.
map.on('mouseleave', 'water', () => {
    console.log('A mouseleave event occurred.');
});
mousemove

Descript

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 Map#on, the event listener will fire only when the the cursor is inside a visible portion of the specified layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('mousemove', () => {
    console.log('A mousemove event has occurred.');
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('mousemove', 'poi-label', () => {
    console.log('A mousemove event has occurred on a visible portion of the poi-label layer.');
});
mouseout

Descript

Fired when a point device (usually a mouse) leaves the map's canvas.

Type

  • MapMouseEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the pointing device leaves
// the map's canvas.
map.on('mouseout', () => {
    console.log('A mouseout event occurred.');
});
mouseover

Descript

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 Map#on, the event listener will fire only when the the cursor is moved inside a visible portion of the specifed layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('mouseover', () => {
    console.log('A mouseover event has occurred.');
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('mouseover', 'poi-label', () => {
    console.log('A mouseover event has occurred on a visible portion of the poi-label layer.');
});
mouseup

Descript

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 Map#on, the event listener will fire only when the the cursor is released while inside a visible portion of the specifed layer.

Type

  • MapMouseEvent

Examples

// Initialize the map
const map = new routogl.Map({});
// Set an event listener
map.on('mouseup', () => {
    console.log('A mouseup event has occurred.');
});
// Initialize the map
const map = new routogl.Map({});
// Set an event listener for a specific layer
map.on('mouseup', 'poi-label', () => {
    console.log('A mouseup event has occurred on a visible portion of the poi-label layer.');
});
move

Descript

Fired repeatedly during an animated transition from one view to another, as the result of either user interaction or methods such as Map#flyTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map.
const map = new routogl.Map({});
// Set an event listener that fires repeatedly during an animated transition.
map.on('move', () => {
    console.log('A move event occurred.');
});
moveend

Descript

Fired just after the map completes a transition from one view to another, as the result of either user interaction or methods such as Map#jumpTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after the map completes a transition.
map.on('moveend', () => {
    console.log('A moveend event occurred.');
});
movestart

Descript

Fired just before the map begins a transition from one view to another, as the result of either user interaction or methods such as Map#jumpTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map.
const map = new routogl.Map({});
// Set an event listener that fires just before the map begins a transition from one view to another.
map.on('movestart', () => {
    console.log('A movestart` event occurred.');
});
pitch

Descript

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 Map#flyTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// repeatedly during a pitch (tilt) transition.
map.on('pitch', () => {
    console.log('A pitch event occurred.');
});
pitchend

Descript

Fired immediately after the map's pitch (tilt) finishes changing as the result of either user interaction or methods such as Map#flyTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after a pitch (tilt) transition ends.
map.on('pitchend', () => {
    console.log('A pitchend event occurred.');
});
pitchstart

Descript

Fired whenever the map's pitch (tilt) begins a change as the result of either user interaction or methods such as Map#flyTo .

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just before a pitch (tilt) transition starts.
map.on('pitchstart', () => {
    console.log('A pitchstart event occurred.');
});
preclick

Descript

Triggered when a click event occurs and is fired before the click event. Primarily implemented to ensure closeOnClick for pop-ups is fired before any other listeners.

Type

  • MapMouseEvent

remove

Descript

Fired immediately after the map has been removed with Map.event:remove.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after the map is removed.
map.on('remove', () => {
    console.log('A remove event occurred.');
});
render

Descript

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.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// whenever the map is drawn to the screen.
map.on('render', () => {
    console.log('A render event occurred.');
});
renderstart

Descript

Fired whenever the rendering process of the map is started. This event can be used in pair with the "render" event, to measure the time spent on the CPU during the rendering of a single frame.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the map begins rendering.
map.on('renderstart', () => {
    console.log('A renderstart event occurred.');
});
resize

Descript

Fired immediately after the map has been resized.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// immediately after the map has been resized.
map.on('resize', () => {
    console.log('A resize event occurred.');
});
rotate

Descript

Fired repeatedly during a "drag to rotate" interaction. See DragRotateHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// repeatedly during "drag to rotate" interaction.
map.on('rotate', () => {
    console.log('A rotate event occurred.');
});
rotateend

Descript

Fired when a "drag to rotate" interaction ends. See DragRotateHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after a "drag to rotate" interaction ends.
map.on('rotateend', () => {
    console.log('A rotateend event occurred.');
});
rotatestart

Descript

Fired when a "drag to rotate" interaction starts. See DragRotateHandler.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just before a "drag to rotate" interaction starts.
map.on('rotatestart', () => {
    console.log('A rotatestart event occurred.');
});
sourcedata

Descript

Fired when one of the map's sources loads or changes, including if a tile belonging to a source loads or changes. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when one of the map's sources loads or changes.
map.on('sourcedata', () => {
    console.log('A sourcedata event occurred.');
});
sourcedataloading

Descript

Fired when one of the map's sources begins loading or changing asynchronously. All `sourcedataloading` events are followed by a `sourcedata` or `error` event. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the map's sources begin loading or
// changing asynchronously.
map.on('sourcedataloading', () => {
    console.log('A sourcedataloading event occurred.');
});
styledata

Descript

Fired when the map's style loads or changes. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the map's style loads or changes.
map.on('styledata', () => {
    console.log('A styledata event occurred.');
});
styledataloading

Descript

Fired when the map's style begins loading or changing asynchronously. All `styledataloading` events are followed by a `styledata` or `error` event. See MapDataEvent for more information.

Type

  • MapDataEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the map's style begins loading or
// changing asynchronously.
map.on('styledataloading', () => {
    console.log('A styledataloading event occurred.');
});
styleimagemissing

Properties

Name Type Description
id string The id of the missing image.

Descript

Fired when an icon or pattern needed by the style is missing. The missing image can be added with 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.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when an icon or pattern is missing.
map.on('styleimagemissing', () => {
    console.log('A styleimagemissing event occurred.');
});
touchcancel

Descript

Fired when a [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/Events/touchcancel) event occurs within the map.

Type

  • MapTouchEvent

Example

// Initialize the map.
const map = new routogl.Map({});
// Set an event listener that fires when a `touchcancel` event occurs within the map.
map.on('touchcancel', () => {
    console.log('A touchcancel event occurred.');
});
touchend

Descript

Fired when a [`touchend`](https://developer.mozilla.org/en-US/docs/Web/Events/touchend) event occurs within the map.

Type

  • MapTouchEvent

Example

// Initialize the map.
const map = new routogl.Map({});
// Set an event listener that fires when a `touchstart` event occurs within the map.
map.on('touchstart', () => {
    console.log('A touchstart event occurred.');
});
touchmove

Descript

Fired when a [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/Events/touchmove) event occurs within the map.

Type

  • MapTouchEvent

Example

// Initialize the map.
const map = new routogl.Map({});
// Set an event listener that fires when a touchmove event occurs within the map.
map.on('touchmove', () => {
    console.log('A touchmove event occurred.');
});
touchstart

Descript

Fired when a [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/Events/touchstart) event occurs within the map.

Type

  • MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when a `touchstart` event occurs within the map.
map.on('touchstart', () => {
    console.log('A touchstart event occurred.');
});
webglcontextlost

Descript

Fired when the WebGL context is lost.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the WebGL context is lost.
map.on('webglcontextlost', () => {
    console.log('A webglcontextlost event occurred.');
});
webglcontextrestored

Descript

Fired when the WebGL context is restored.

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when the WebGL context is restored.
map.on('webglcontextrestored', () => {
    console.log('A webglcontextrestored event occurred.');
});
wheel

Descript

Fired when a [`wheel`](https://developer.mozilla.org/en-US/docs/Web/Events/wheel) event occurs within the map.

Type

  • MapWheelEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// when a wheel event occurs within the map.
map.on('wheel', () => {
    console.log('A wheel event occurred.');
});
zoom

Descript

Fired repeatedly during an animated transition from one zoom level to another, as the result of either user interaction or methods such as Map#flyTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// repeatedly during a zoom transition.
map.on('zoom', () => {
    console.log('A zoom event occurred.');
});
zoomend

Descript

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 Map#flyTo. The zoom transition will usually end before rendering is finished, so if you need to wait for rendering to finish, use the Map.event:idle event instead.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just after a zoom transition finishes.
map.on('zoomend', () => {
    console.log('A zoomend event occurred.');
});
zoomstart

Descript

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 Map#flyTo.

Type

  • MapMouseEvent | MapTouchEvent

Example

// Initialize the map
const map = new routogl.Map({});
// Set an event listener that fires
// just before a zoom transition starts.
map.on('zoomstart', () => {
    console.log('A zoomstart event occurred.');
});

routogl.AttributionControl

Description

An AttributionControl control presents the map's attribution information.


Constructor

new routogl.AttributionControl()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

map.addControl(new routogl.AttributionControl({ compact: true }), 'bottom-right');

routogl.BoxZoomHandler

Description

The BoxZoomHandler allows the user to zoom the map to fit within a bounding box.
The bounding box is defined by clicking and holding shift while dragging the cursor.


Constructor

new routogl.BoxZoomHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 박스 줌 활성화
map['boxZoom'].enable();

// 박스 줌 비활성화
map['boxZoom'].disable();

routogl.DoubleClickZoomHandler

Description

The DoubleClickZoomHandler allows the user to zoom the map at a point by double clicking or double tapping.


Constructor

new routogl.DoubleClickZoomHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 더블클릭 줌 활성화
map['doubleClickZoom'].enable();

// 더블클릭 줌 비활성화
map['doubleClickZoom'].disable();

routogl.DragPanHandler

Description

The DragPanHandler allows the user to pan the map by clicking and dragging the cursor.


Constructor

new routogl.DragPanHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 드래그 팬 활성화
map['dragPan'].enable();

// 드래그 팬 비활성화
map['dragPan'].disable();

routogl.DragRotateHandler

Description

The DragRotateHandler allows the user to rotate the map by clicking and dragging the cursor while holding the right mouse button or ctrl key.


Constructor

new routogl.DragRotateHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 드래그 로테이트 활성화
map['dragRotate'].enable();

// 드래그 로테이트 비활성화
map['dragRotate'].disable();

routogl.FullscreenControl

Description

A FullscreenControl control contains a button for toggling the map in and out of fullscreen mode.


Constructor

new routogl.FullscreenControl()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

map.addControl(new routogl.FullscreenControl());

routogl.GeoJSONSource

Description

A source containing GeoJSON.


Constructor

new routogl.GeoJSONSource()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

map.addSource('some id', {
  type: 'geojson',
  data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'
});

map.addSource('some id', {
  type: 'geojson',
  data: {
    "type": "FeatureCollection",
    "features": [{
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          -76.53063297271729,
          39.18174077994108
        ]
      }
    }]
  }
});

map.getSource('some id').setData({
  "type": "FeatureCollection",
  "features": [{
    "type": "Feature",
    "properties": {"name": "Null Island"},
    "geometry": {
      "type": "Point",
      "coordinates": [ 0, 0 ]
    }
  }]
});

routogl.GeolocateControl

Description

A GeolocateControl control provides a button that uses the browser's geolocation API to locate the user on the map.


Constructor

new routogl.GeolocateControl()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

map.addControl(new routogl.GeolocateControl({
  positionOptions: {
    enableHighAccuracy: true
  },
  trackUserLocation: true,
  showUserHeading: true
}));

routogl.ImageSource

Description

A data source containing an image.


Constructor

new routogl.ImageSource()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// add to map
map.addSource('some id', {
  type: 'image',
  url: 'https://www.mapbox.com/images/foo.png',
  coordinates: [
    [-76.54, 39.18],
    [-76.52, 39.18],
    [-76.52, 39.17],
    [-76.54, 39.17]
  ]
});

// update coordinates
const mySource = map.getSource('some id');
mySource.setCoordinates([
  [-76.54335737228394, 39.18579907229748],
  [-76.52803659439087, 39.1838364847587],
  [-76.5295386314392, 39.17683392507606],
  [-76.54520273208618, 39.17876344106642]
]);

// update url and coordinates simultaneously
mySource.updateImage({
  url: 'https://www.mapbox.com/images/bar.png',
  coordinates: [
    [-76.54335737228394, 39.18579907229748],
    [-76.52803659439087, 39.1838364847587],
    [-76.5295386314392, 39.17683392507606],
    [-76.54520273208618, 39.17876344106642]
  ]
});

map.removeSource('some id');  // remove

routogl.IndoorLayer

Description

Indoor Layer (예제)


Constructor

new routogl.IndoorLayer(IndoorLayerOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [126.4392, 37.4625], // starting position [lng, lat], 인천공항
  zoom: 16, // starting zoom
});

const IndoorLayer = new routogl.IndoorLayer({
  map,
});

Parameters

Name {Type} Description
IndoorLayerOption { Object } Indoor Options.

Extends

  • Observable


Methods

destroy()

Descript

remove IndoorArea Layer

reset()

Descript

reset IndoorArea Layer

setMap(map)

Descript

Add IndoorArea Layer to Map

Parameters

Name {Type} Description
map { routogl/Map } 지도 객체
setOptions(IndoorLayerOption, opt)

Descript

실내 지도 옵션 적용

Parameters

Name {Type} Description
IndoorLayerOption { Object } Indoor Options.

routogl.KeyboardHandler

Description

The KeyboardHandler allows the user to zoom, rotate, and pan the map using the following keyboard shortcuts: = / +: Increase the zoom level by 1. Shift-= / Shift-+: Increase the zoom level by 2. -: Decrease the zoom level by 1. Shift--: Decrease the zoom level by 2. Arrow keys: Pan by 100 pixels. Shift+⇢: Increase the rotation by 15 degrees. Shift+⇠: Decrease the rotation by 15 degrees. Shift+⇡: Increase the pitch by 10 degrees. Shift+⇣: Decrease the pitch by 10 degrees.


Constructor

new routogl.KeyboardHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 키보드 활성화
map['keyboard'].enable();

// 키보드 비활성화
map['keyboard'].disable();

routogl.LngLat

Description

A LngLat object represents a given longitude and latitude coordinate, measured in degrees.


Constructor

new routogl.LngLat()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const ll = new routogl.LngLat(-123.9749, 40.7736);
console.log(ll.lng); // = -123.9749

routogl.LngLatBounds

Description

A LngLatBounds object represents a geographical bounding box, defined by its southwest and northeast points in longitude and latitude.


Constructor

new routogl.LngLatBounds()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const sw = new routogl.LngLat(-73.9876, 40.7661);
const ne = new routogl.LngLat(-73.9397, 40.8002);
const llb = new routogl.LngLatBounds(sw, ne);

routogl.MapMouseEvent

Description

`MapBoxZoomEvent` is a class used to generate the events 'boxzoomstart', 'boxzoomend', and 'boxzoomcancel'. For a full list of available events, see [`Map` events](/mapbox-gl-js/api/map/#map-events).


Constructor

new routogl.MapMouseEvent()


See:
  • [Reference: `Map` events API documentation](https://docs.mapbox.com/mapbox-gl-js/api/map/#map-events)
  • [Example: Highlight features within a bounding box](https://docs.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)

Examples

// Example trigger of a BoxZoomEvent of type "boxzoomstart"
map.on('boxzoomstart', (e) => {
    console.log('event type:', e.type);
    // event type: boxzoomstart
});
// Example of a BoxZoomEvent of type "boxzoomstart"
// {
//   originalEvent: {...},
//   type: "boxzoomstart",
//   target: {...}
// }

routogl.MapMouseEvent

Description

MapMouseEvent is a class used by other classes to generate mouse events of specific types such as 'click' or 'hover'


Constructor

new routogl.MapMouseEvent()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// Example of a MapMouseEvent of type "click"
map.on('click', (e) => {
  console.log(e);
  // {
  //   lngLat: {
  //     lng: 40.203,
  //     lat: -74.451
  //   },
  //   originalEvent: {...},
  //   point: {
  //     x: 266,
  //     y: 464
  //   },
  //    target: {...},
  //    type: "click"
  // }
});

routogl.MapTouchEvent

Description

MapTouchEvent is a class used by other classes to generate mouse events of specific types such as 'touchstart' or 'touchend'.


Constructor

new routogl.MapTouchEvent()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// Example of a MapTouchEvent of type "touch"
map.on('touchstart', (e) => {
  console.log(e);
  // {
  //    lngLat: {
  //      lng: 40.203,
  //      lat: -74.451
  //    },
  //    lngLats: [
  //      {
  //        lng: 40.203,
  //        lat: -74.451
  //      }
  //    ],
  //    originalEvent: {...},
  //    point: {
  //      x: 266,
  //      y: 464
  //    },
  //    points: [
  //      {
  //        x: 266,
  //        y: 464
  //      }
  //    ]
  //    preventDefault(),
  //    target: {...},
  //    type: "touchstart"
  // }
});

routogl.Marker

Description

Creates a marker component.


Constructor

new routogl.Marker(markerOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const lngLat = [127.0586339, 37.507009];

const el = document.createElement('div');
el.className = 'marker';
el.style.backgroundColor = 'white';
el.style.padding = '2px';
el.style.borderRadius = '3px';
el.style.fontSize = '12px';
el.innerText = text;

const marker = new routogl.Marker(el).setLngLat(lngLat).addTo(map);

Parameters

Name {Type} Description
markerOption { Object } Marker Options
Properties
Name {Type} Description
color { string } 기본 마커 색상을 선택합니다. default value: '#3FB1CE'

routogl.NavigationControl

Description

A NavigationControl control contains zoom buttons and a compass.


Constructor

new routogl.NavigationControl()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const nav = new routogl.NavigationControl({
  visualizePitch: true
});
map.addControl(nav, 'bottom-right');

routogl.ParkingLayer

Description

Parking Lot Layer (예제)


Constructor

new routogl.ParkingLayer(parkingLayerOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.05874, 37.511536], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 지하주차장 지도 표시
map.on('style.load', () => {
  const parkingLayer = new routogl.ParkingLayer({
    map,    
  });
});

Parameters

Name {Type} Description
parkingLayerOption { Object } Parking Lot Options.

Extends

  • Observable


Methods

destroy()

Descript

remove Parking Lot Layer

reset()

Descript

reset Parking Lot Layer

setMap(map)

Descript

Add Parking Lot Layer to Map

Parameters

Name {Type} Description
map { routogl/Map } 지도 객체

routogl.Point

Description

A Point geometry object, which has x and y properties representing screen coordinates in pixels.


Constructor

new routogl.Point()


Example

const point = new routogl.Point(-77, 38);

routogl.Popup

Description

A popup component.


Constructor

new routogl.Popup(popupOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const lngLat = [127.0586339, 37.507009];

const popup = new routogl.Popup({ offset: 35 }).setLngLat(lngLat).setText('예제 마커 1').addTo(map);

Parameters

Name {Type} Description
popupOption { Object } Popup Options.
Properties
Name {Type} Description
className { string } 팝업 엘리먼트의 클래스명을 지정합니다.

routogl.RoutoDraw

Description

그리기 도구


Constructor

new routogl.RoutoDraw(RoutoDrawOption, opt)


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.05874, 37.511536], // starting position [lng, lat]
  zoom: 16, // starting zoom
});

const routoDraw = new routogl.RoutoDraw();
map.addControl(routoDraw);

Parameters

Name {Type} Description
RoutoDrawOption { Object } 그리기 도구 옵션

routogl.ScaleControl

Description

A ScaleControl control displays the ratio of a distance on the map to the corresponding distance on the ground.


Constructor

new routogl.ScaleControl()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

const scale = new routogl.ScaleControl({
    maxWidth: 80,
    unit: 'imperial'
});
map.addControl(scale);

scale.setUnit('metric');

routogl.ScrollZoomHandler

Description

The ScrollZoomHandler allows the user to zoom the map by scrolling.


Constructor

new routogl.ScrollZoomHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 스크롤줌 활성화
map['scrollZoom'].enable();

// 스크롤줌 비활성화
map['scrollZoom'].disable();

routogl.TouchPitchHandler

Description

The TouchPitchHandler allows the user to pitch the map by dragging up and down with two fingers.


Constructor

new routogl.TouchPitchHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 터치 피치 활성화
map['touchZoomRotate'].enable();

// 터치 피치 비활성화
map['touchZoomRotate'].disable();

routogl.TouchZoomRotateHandler

Description

The TouchZoomRotateHandler allows the user to zoom and rotate the map by pinching on a touchscreen.


Constructor

new routogl.TouchZoomRotateHandler()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

// 터치 줌 로테이트 활성화
map['touchZoomRotate'].enable();

// 터치 줌 로테이트 비활성화
map['touchZoomRotate'].disable();

routogl.VectorTileSource

Description

A source containing vector tiles in Mapbox Vector Tile format.


Constructor

new routogl.VectorTileSource()


Example

const map = new routogl.Map({
  container: 'map', // container ID
  style: routogl.RoutoStyle.LIGHT,
  center: [127.0586339, 37.507009], // starting position [lng, lat]
  zoom: 17, // starting zoom
});

map.addSource('some id', {
  type: 'vector',
  url: 'mapbox://mapbox.mapbox-streets-v8'
});

map.addSource('some id', {
  type: 'vector',
  tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],
  minzoom: 6,
  maxzoom: 14
});

map.getSource('some id').setUrl("mapbox://mapbox.mapbox-streets-v8");

map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);