Location:

Map Class

Map Class

Map object class, a class that encapsulates the interface's property settings, layer changes, event interactions, and more.

MapOptionsTypeDescription

container

HTMLElement | string

The ID value of the map container DIV or the DIV object, which needs to be empty in the container.

minZoom

Number

Set the minimum zoom level for the map.

maxZoom

Number

Set the map's maximum zoom level.

hash

Boolean

defaults to false. When this property is true, the map's position (zoom, center latitude, center longitude, orientation) will be synchronized with the hash of the page URL, for example, https://lbs.navinfo.com/open-api/to/my/ Page.html#2.59/39.26/53.07/-24.1/60.

interactive

Boolean

The default is true. When this property is false, map interaction will be prohibited, such as dragging the map by mouse, moving the map by keyboard, etc., but it does not affect the click event.

pitchWithRotate

Boolean

The default is true. When this property is false, the right button will be prohibited from rotating to the map tilt.

preserveDrawingBuffer

Boolean

The default is false. When this property is true, the map canvas can be exported to PNG using the map.getCanvas().toDataURL() method. The best performance is true by default.

maxBounds

LngLatBounds

Example of setting map range: [[116.319665, 39.855919], [116.468324, 39.9756]]

scrollZoom

Boolean

The default is true. When this property is false, the mouse will be prohibited from scrolling and zooming the map

dragRotate

Boolean

defaults to true, when this property is false, Disable mouse drag and drop to rotate the map

dragPan

Boolean

The default is true. When this property is false, the mouse drag and drop panning map will be disabled

keyboard

Boolean

The default is true. When this property is false, the keyboard panning map will be disabled

doubleClickZoom

Boolean

defaults to true when this property is When false, the mouse will be disabled by double-clicking the zoom map

touchZoomRotate

Boolean

The default is true when this genus When false, the gesture pinch pinch is rotated to rotate or zoom the map (mobile only)

trackResize

Boolean

The default is true. When this property is false, the map will be automatically adjusted when the map is resized with the browser window.

center

LngLat

The initial map Geographic Center Point

zoom

Number

Map's initial zoom level

bearing

Number

the initial orientation of the map (rotation) in degrees The unit measures counterclockwise from the north

bounds

LngLatBounds

The initial boundary of the map

pitch

Number

The initial pitch (tilt) of the map, measured in degrees away from the screen plane (0-60).

renderWorldCopies

Boolean

When the property is true, multiple copies of the world will be rendered when zoomed out.


MethodReturn ValueDescription

scrollZoom

The member object in the Map instance contains 3 methods isEnable, enable, disable

dragRotate

The member object in the Map instance contains 4 methods isEnable, isActive, enable, disable

dragPan

Map instance The member object contains 4 methods isEnable, isActive, enable, disable

keyboard

The member object in the Map instance contains 3 methods isEnable, enable, disable

doubleClickZoom

A member object in a Map instance containing 3 methods isEnable, enable, disable

touchZoomRotate

Map instance Member object, containing 3 methods isEnable , enable, disable

addControl(control,position)

control (the controller class of the instance); position(string) sets the position of the controller, valid parameters 'top-left' , 'top-right' , 'bottom-left' , and 'bottom-right' .

removeControl(control)

Remove added controllers

getBounds()

LngLatBounds

Returns the current map boundary range, northwest and southeast coordinates

fitBounds(LngLatBounds)

Adjust maps to this range

getMaxBounds()

LngLatBounds

Back to the maximum map range set, Northwest and Southeast coordinates

setMaxBounds(LngLatBounds)

Set the maximum map extent, northwest and southeast coordinates

setMinZoom(minZoom)

Parameter type (Number | null | undefined)Number sets the minimum zoom level (0-24) and scales to the new minimum if the current zoom level of the map is below the new minimum. If you want to clear the minimum level, set null | undefined

getMinZoom()

Number

Return the minimum allowable zoom level for the map

setMaxZoom(minZoom)

Parameter type (Number | null | undefined). Number sets the maximum zoom level (0-24) and scales to the new maximum if the map's current zoom level is higher than the new maximum. If you want to clear the maximum level, set null | undefined

getMaxZoom()

Number

Return the maximum allowable zoom level for the map

getRenderWorldCopies()

Boolean

Returns whether multiple world copies will be rendered when zoomed out. If true, multiple copies will be rendered

setRenderWorldCopies(Boolean)

Sets whether multiple world copies will be rendered when zoomed out. If true, multiple copies will be rendered

project(lnglat)

Point

Returns a Point object representing the coordinates of the geographic coordinates relative to the map. The container corresponds to the specified geographic location

unproject(point)

Lnglat

Returns an Lnglat object representing the specified pixel coordinates Corresponding geographic coordinates

on(type,listener)

Adds a listener for the map-specified type event. Type: the type of event to be registered (string); listener: the function that triggered the event call (function)

on(type,layer,listener)

Add a listener for the map overlay specified type event. Type: the type of event to be registered (string); layer: the ID of the vector graphic overlay. Listener: The function (function) that triggers the event call

off(type,listener)

Remove the previously added event add listener. Type: the previously registered event type (string); listener: previously added function (function)

off(type,layer,listener)

Remove the previously added event add listener. Type: the previously registered event type (string); layer: the previously added overlay ID. Listener: previously added function (function)

addLayer(layer,beforeId)

Add a cover to the map. Layer: Polygon, polyline, Circle, CircleMarker and other overlay objects or custom GeoJSon objects. beforeId: ID inserted before a cover

moveLayer(layerId, beforeId)

Moving the overlay order. layerId: the id of the overlay to move; beforeId: the id to move to the overlay

removeLayer()

The member object in the Map instance contains 4 methods isEnable, isActive, enable, disable

remove()

Clear and release the association associated with this map All internal resources. This includes DOM elements, event bindings, Web workers, and WebGL resources. Once you've finished using the map, use this method and want to make sure it no longer consumes browser resources. After that, you must not call any other method on the map

getCenter()

Lnglat

Get the coordinates of the center point of the current map

setCenter(LngLat)

Set the map center point coordinates, equivalent to jumpTo({center: center})

panBy(offset:[x,y],options)

Move the map in x and y directions in pixels, with x being right and y down being positive

panTo(LngLat )

The center of the map is panned to the specified point.

getZoom()

Number

Get the current zoom level of the map

setZoom(zoom)

Set the map zoom level, equivalent to jumpTo({zoom: zoom})

zoomTo()

The center of the map is panned to the specified point position

zoomIn()

Map raises one Zoom level

zoomOut()

Map reduces a zoom level

jumpTo(options)

Change the map center point, zoom level combination object, no animation. Example: map.jumpTo({center: [116.21, 39.213], zoom: 9})

flyTo(options)

Change the combination of the center point of the map, the zoom level, and have a flight animation. Example: map.flyTo({center: [116.21, 39.213], zoom: 9})

TOP