Skip to content

Documentation / @geoverse/core-ol / GMap

Class: GMap ​

Defined in: packages/core-ol/src/map/gmap.ts:148

GeoVerse 地图容器,继承自 ol/Map。

相对 ol/Map 的增强:

  • 自动注册国内坐标系(GCJ-02 / BD-09 / EPSG:3395,幂等)
  • 内置高德/百度/天地图/海图底图与底图切换(含图层重投影)
  • 地图级 pointer 事件统一派发为要素级 click / mouseover / mouseout
  • 一组以"经纬度"为参数的便捷视图方法

Extends ​

  • Map

Constructors ​

Constructor ​

ts
new GMap(opts?): GMap;

Defined in: packages/core-ol/src/map/gmap.ts:149

Parameters ​

opts? ​

GMapOptions = {}

Returns ​

GMap

Overrides ​

ts
Map.constructor

Properties ​

controls ​

ts
protected controls: Collection<Control>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:421

Inherited from ​

ts
Map.controls

disposed ​

ts
protected disposed: boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Disposable.d.ts:15

The object has already been disposed.

Inherited from ​

ts
Map.disposed

interactions ​

ts
protected interactions: Collection<Interaction>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:426

Inherited from ​

ts
Map.interactions

on ​

ts
on: MapEventHandler<EventsKey>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:290

Inherited from ​

ts
Map.on

once ​

ts
once: MapEventHandler<EventsKey>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:294

Inherited from ​

ts
Map.once

un ​

ts
un: MapEventHandler<void>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:298

Inherited from ​

ts
Map.un

viewport_ ​

ts
viewport_: HTMLDivElement | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:376

Inherited from ​

ts
Map.viewport_

Methods ​

addChangeListener() ​

ts
addChangeListener(key, listener): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:145

Parameters ​

key ​

string

Key name.

listener ​

Listener

Listener.

Returns ​

void

Inherited from ​

ts
Map.addChangeListener

addControl() ​

ts
addControl(control): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:458

Add the given control to the map.

Parameters ​

control ​

Control

Control.

Returns ​

void

Api ​

Inherited from ​

ts
Map.addControl

addEventListener() ​

ts
addEventListener(type, listener): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/events/Target.d.ts:50

Parameters ​

type ​

string

Type.

listener ​

Listener

Listener.

Returns ​

void

Inherited from ​

ts
Map.addEventListener

addInteraction() ​

ts
addInteraction(interaction): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:468

Add the given interaction to the map. If you want to add an interaction at another point of the collection use getInteractions() and the methods available on module:ol/Collection~Collection. This can be used to stop the event propagation from the handleEvent function. The interactions get to handle the events in the reverse order of this collection.

Parameters ​

interaction ​

Interaction

Interaction to add.

Returns ​

void

Api ​

Inherited from ​

ts
Map.addInteraction

addLayer() ​

ts
addLayer(layer): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:476

Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on module:ol/Collection~Collection.

Parameters ​

layer ​

BaseLayer<{ [x: string]: any; }>

Layer.

Returns ​

void

Api ​

Inherited from ​

ts
Map.addLayer

addOverlay() ​

ts
addOverlay(overlay): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:487

Add the given overlay to the map.

Parameters ​

overlay ​

Overlay

Overlay.

Returns ​

void

Api ​

Inherited from ​

ts
Map.addOverlay

applyProperties() ​

ts
protected applyProperties(source): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:172

Apply any properties from another object without triggering events.

Parameters ​

source ​

BaseObject

The source object.

Returns ​

void

Inherited from ​

ts
Map.applyProperties

changed() ​

ts
changed(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Observable.d.ts:65

Increases the revision counter and dispatches a 'change' event.

Returns ​

void

Api ​

Inherited from ​

ts
Map.changed

clearDrawSource() ​

ts
clearDrawSource(): void;

Defined in: packages/core-ol/src/map/gmap.ts:557

清空绘制与测量痕迹

Returns ​

void


destroy() ​

ts
destroy(): void;

Defined in: packages/core-ol/src/map/gmap.ts:748

销毁地图:解绑容器并释放资源。 (旧库 dispose() 存在无限递归 bug,此处为修复后的实现)

Returns ​

void


dispatchEvent() ​

ts
dispatchEvent(event): boolean | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/events/Target.d.ts:61

Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

Parameters ​

event ​

string | BaseEvent

Event object.

Returns ​

boolean | undefined

false if anyone called preventDefault on the event object or if any of the listeners returned false.

Api ​

Inherited from ​

ts
Map.dispatchEvent

dispose() ​

ts
dispose(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Disposable.d.ts:19

Clean up.

Returns ​

void

Inherited from ​

ts
Map.dispose

disposeInternal() ​

ts
protected disposeInternal(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Disposable.d.ts:24

Extension point for disposable objects.

Returns ​

void

Inherited from ​

ts
Map.disposeInternal

exportPng() ​

ts
exportPng(options?): void;

Defined in: packages/core-ol/src/map/gmap.ts:683

导出当前地图画面为 PNG 并触发下载

Parameters ​

options? ​

ExportPngOptions = {}

Returns ​

void


forEachFeatureAtPixel() ​

ts
forEachFeatureAtPixel<T>(
   pixel, 
   callback, 
   options?): T | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:515

Detect features that intersect a pixel on the viewport, and execute a callback with each intersecting feature. Layers included in the detection can be configured through the layerFilter option in options. For polygons without a fill, only the stroke will be used for hit detection. Polygons must have a fill style applied to ensure that pixels inside a polygon are detected. The fill can be transparent.

Type Parameters ​

T ​

T

Parameters ​

pixel ​

Pixel

Pixel.

callback ​

(arg0, arg1, arg2) => T

Feature callback. The callback will be called with two arguments. The first argument is one module:ol/Feature~Feature feature or module:ol/render/Feature~RenderFeature render feature at the pixel, the second is the module:ol/layer/Layer~Layer layer of the feature and will be null for unmanaged layers. To stop detection, callback functions can return a truthy value.

options? ​

AtPixelOptions

Optional options.

Returns ​

T | undefined

Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.

Api ​

Inherited from ​

ts
Map.forEachFeatureAtPixel

forEachSmFeatureAtPixel() ​

ts
forEachSmFeatureAtPixel(
   pixel, 
   callback, 
   options?, 
   event?): unknown;

Defined in: packages/core-ol/src/map/gmap.ts:601

同时检测普通要素与海量点 graphic 的像素命中。 海量点图层(MassSource)通过 _forEachFeatureAtCoordinate 协议参与检测。

Parameters ​

pixel ​

number[]

callback ​

(featureOrGraphic, eventOrLayer?) => unknown

options? ​
checkWrapped? ​

boolean

hitTolerance? ​

number

layerFilter? ​

(layer) => boolean

event? ​

unknown

Returns ​

unknown


get() ​

ts
get(key): any;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:114

Gets a value.

Parameters ​

key ​

string

Key name.

Returns ​

any

Value.

Api ​

Inherited from ​

ts
Map.get

getAllFeatures() ​

ts
getAllFeatures(): Feature<Geometry, {
[x: string]: any;
}>[];

Defined in: packages/core-ol/src/map/gmap.ts:491

获取全部矢量要素

Returns ​

Feature<Geometry, { [x: string]: any; }>[]


getAllInfoWindows() ​

ts
getAllInfoWindows(): Overlay[];

Defined in: packages/core-ol/src/map/gmap.ts:534

获取全部信息弹窗

Returns ​

Overlay[]


getAllLayers() ​

ts
getAllLayers(): Layer<Source, LayerRenderer<any>, {
[x: string]: any;
}>[];

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:533

Get all layers from all layer groups.

Returns ​

Layer<Source, LayerRenderer<any>, { [x: string]: any; }>[]

Layers.

Api ​

Inherited from ​

ts
Map.getAllLayers

getBaseLayers() ​

ts
getBaseLayers(): BaseLayer<{
[x: string]: any;
}>[];

Defined in: packages/core-ol/src/map/gmap.ts:375

获取底图图层

Returns ​

BaseLayer<{ [x: string]: any; }>[]


getBounds() ​

ts
getBounds(): number[];

Defined in: packages/core-ol/src/map/gmap.ts:327

当前视野范围(视图投影坐标)

Returns ​

number[]


getCenter() ​

ts
getCenter(): Coordinate;

Defined in: packages/core-ol/src/map/gmap.ts:303

获取中心点(WGS-84 经纬度)

Returns ​

Coordinate


getContainer() ​

ts
getContainer(): HTMLElement | undefined;

Defined in: packages/core-ol/src/map/gmap.ts:339

获取地图容器元素

Returns ​

HTMLElement | undefined


getContentLayers() ​

ts
getContentLayers(): BaseLayer<{
[x: string]: any;
}>[];

Defined in: packages/core-ol/src/map/gmap.ts:396

获取全部内容图层(不含底图)

Returns ​

BaseLayer<{ [x: string]: any; }>[]


getControls() ​

ts
getControls(): Collection<Control>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:608

Get the map controls. Modifying this collection changes the controls associated with the map.

Returns ​

Collection<Control>

Controls.

Api ​

Inherited from ​

ts
Map.getControls

getCoordinateFromPixel() ​

ts
getCoordinateFromPixel(pixel): Coordinate;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:594

Get the coordinate for a given pixel. This returns a coordinate in the user projection.

Parameters ​

pixel ​

Pixel

Pixel position in the map viewport.

Returns ​

Coordinate

The coordinate for the pixel position.

Api ​

Inherited from ​

ts
Map.getCoordinateFromPixel

getCoordinateFromPixelInternal() ​

ts
getCoordinateFromPixelInternal(pixel): Coordinate;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:601

Get the coordinate for a given pixel. This returns a coordinate in the map view projection.

Parameters ​

pixel ​

Pixel

Pixel position in the map viewport.

Returns ​

Coordinate

The coordinate for the pixel position.

Inherited from ​

ts
Map.getCoordinateFromPixelInternal

getDistance() ​

ts
getDistance(c1, c2): number;

Defined in: packages/core-ol/src/map/gmap.ts:322

两经纬度点之间的球面距离(米)

Parameters ​

c1 ​

Coordinate

c2 ​

Coordinate

Returns ​

number


getEventCoordinate() ​

ts
getEventCoordinate(event): Coordinate;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:552

Returns the coordinate in user projection for a browser event.

Parameters ​

event ​

MouseEvent

Event.

Returns ​

Coordinate

Coordinate.

Api ​

Inherited from ​

ts
Map.getEventCoordinate

getEventCoordinateInternal() ​

ts
getEventCoordinateInternal(event): Coordinate;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:558

Returns the coordinate in view projection for a browser event.

Parameters ​

event ​

MouseEvent

Event.

Returns ​

Coordinate

Coordinate.

Inherited from ​

ts
Map.getEventCoordinateInternal

getEventPixel() ​

ts
getEventPixel(event): Pixel;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:565

Returns the map pixel position for a browser event relative to the viewport.

Parameters ​

event ​

| UIEvent | { clientX: number; clientY: number; }

Event.

Returns ​

Pixel

Pixel.

Api ​

Inherited from ​

ts
Map.getEventPixel

getFeatureById() ​

ts
getFeatureById(id): 
  | Feature<Geometry, {
[x: string]: any;
}>
  | undefined;

Defined in: packages/core-ol/src/map/gmap.ts:480

在全部矢量图层中按 id 检索要素

Parameters ​

id ​

string | number

Returns ​

| Feature<Geometry, { [x: string]: any; }> | undefined


getFeaturesAtPixel() ​

ts
getFeaturesAtPixel(pixel, options?): FeatureLike[];

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:527

Get all features that intersect a pixel on the viewport. For polygons without a fill, only the stroke will be used for hit detection. Polygons must have a fill style applied to ensure that pixels inside a polygon are detected. The fill can be transparent.

Parameters ​

pixel ​

Pixel

Pixel.

options? ​

AtPixelOptions

Optional options.

Returns ​

FeatureLike[]

The detected features or an empty array if none were found.

Api ​

Inherited from ​

ts
Map.getFeaturesAtPixel

getInfoWindowById() ​

ts
getInfoWindowById(id): Overlay | undefined;

Defined in: packages/core-ol/src/map/gmap.ts:527

按 id 获取信息弹窗(overlay)

Parameters ​

id ​

string | number

Returns ​

Overlay | undefined


getInteractions() ​

ts
getInteractions(): Collection<Interaction>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:633

Get the map interactions. Modifying this collection changes the interactions associated with the map.

Interactions are used for e.g. pan, zoom and rotate.

Returns ​

Collection<Interaction>

Interactions.

Api ​

Inherited from ​

ts
Map.getInteractions

getKeys() ​

ts
getKeys(): string[];

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:120

Get a list of object property names.

Returns ​

string[]

List of property names.

Api ​

Inherited from ​

ts
Map.getKeys

getLayerById() ​

ts
getLayerById(id): 
  | BaseLayer<{
[x: string]: any;
}>
  | undefined;

Defined in: packages/core-ol/src/map/gmap.ts:467

按 id 属性获取内容图层

Parameters ​

id ​

string | number

Returns ​

| BaseLayer<{ [x: string]: any; }> | undefined


getLayerGroup() ​

ts
getLayerGroup(): LayerGroup;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:640

Get the layergroup associated with this map.

Returns ​

LayerGroup

A layer group containing the layers in this map.

Observable ​

Api ​

Inherited from ​

ts
Map.getLayerGroup

getLayers() ​

ts
getLayers(): Collection<BaseLayer<{
[x: string]: any;
}>>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:652

Get the collection of layers associated with this map.

Returns ​

Collection<BaseLayer<{ [x: string]: any; }>>

Layers.

Api ​

Inherited from ​

ts
Map.getLayers

getListeners() ​

ts
getListeners(type): Listener[] | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/events/Target.d.ts:69

Get the listeners for a specified event type. Listeners are returned in the order that they will be called in.

Parameters ​

type ​

string

Type.

Returns ​

Listener[] | undefined

Listeners.

Inherited from ​

ts
Map.getListeners

getLoadingOrNotReady() ​

ts
getLoadingOrNotReady(): boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:656

Returns ​

boolean

Layers have sources that are still loading.

Inherited from ​

ts
Map.getLoadingOrNotReady

getMaxZoom() ​

ts
getMaxZoom(): number;

Defined in: packages/core-ol/src/map/gmap.ts:294

Returns ​

number


getMinZoom() ​

ts
getMinZoom(): number;

Defined in: packages/core-ol/src/map/gmap.ts:298

Returns ​

number


getOverlayById() ​

ts
getOverlayById(id): Overlay | null;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:624

Get an overlay by its identifier (the value returned by overlay.getId()). Note that the index treats string and numeric identifiers as the same. So map.getOverlayById(2) will return an overlay with id '2' or 2.

Parameters ​

id ​

string | number

Overlay identifier.

Returns ​

Overlay | null

Overlay.

Api ​

Inherited from ​

ts
Map.getOverlayById

getOverlayContainer() ​

ts
getOverlayContainer(): HTMLElement;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:717

Get the element that serves as the container for overlays. Elements added to this container will let mousedown and touchstart events through to the map, so clicks and gestures on an overlay will trigger module:ol/MapBrowserEvent~MapBrowserEvent events.

Returns ​

HTMLElement

The map's overlay container.

Inherited from ​

ts
Map.getOverlayContainer

getOverlayContainerStopEvent() ​

ts
getOverlayContainerStopEvent(): HTMLElement;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:725

Get the element that serves as a container for overlays that don't allow event propagation. Elements added to this container won't let mousedown and touchstart events through to the map, so clicks and gestures on an overlay don't trigger any module:ol/MapBrowserEvent~MapBrowserEvent.

Returns ​

HTMLElement

The map's overlay container that stops events.

Inherited from ​

ts
Map.getOverlayContainerStopEvent

getOverlays() ​

ts
getOverlays(): Collection<Overlay>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:615

Get the map overlays. Modifying this collection changes the overlays associated with the map.

Returns ​

Collection<Overlay>

Overlays.

Api ​

Inherited from ​

ts
Map.getOverlays

getOwnerDocument() ​

ts
getOwnerDocument(): Document;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:729

Returns ​

Document

The document where the map is displayed.

Inherited from ​

ts
Map.getOwnerDocument

getPixelFromCoordinate() ​

ts
getPixelFromCoordinate(coordinate): Pixel;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:664

Get the pixel for a coordinate. This takes a coordinate in the user projection and returns the corresponding pixel.

Parameters ​

coordinate ​

Coordinate

A map coordinate.

Returns ​

Pixel

A pixel position in the map viewport.

Api ​

Inherited from ​

ts
Map.getPixelFromCoordinate

getPixelFromCoordinateInternal() ​

ts
getPixelFromCoordinateInternal(coordinate): Pixel;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:671

Get the pixel for a coordinate. This takes a coordinate in the map view projection and returns the corresponding pixel.

Parameters ​

coordinate ​

Coordinate

A map coordinate.

Returns ​

Pixel

A pixel position in the map viewport.

Inherited from ​

ts
Map.getPixelFromCoordinateInternal

getPixelRatio() ​

ts
getPixelRatio(): number;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:677

Get the pixel ratio of the rendered map.

Returns ​

number

Pixel ratio.

Api ​

Inherited from ​

ts
Map.getPixelRatio

getProperties() ​

ts
getProperties(): NoInfer<{
[x: string]: any;
}>;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:126

Get an object of all property names and values.

Returns ​

NoInfer<{ [x: string]: any; }>

Object.

Api ​

Inherited from ​

ts
Map.getProperties

getPropertiesInternal() ​

ts
getPropertiesInternal(): 
  | Partial<NoInfer<{
[x: string]: any;
}>>
  | null;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:131

Get an object of all property names and values.

Returns ​

| Partial<NoInfer<{ [x: string]: any; }>> | null

Object.

Inherited from ​

ts
Map.getPropertiesInternal

getRenderer() ​

ts
getRenderer(): MapRenderer | null;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:688

Get the map renderer.

Returns ​

MapRenderer | null

Renderer

Inherited from ​

ts
Map.getRenderer

getRevision() ​

ts
getRevision(): number;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Observable.d.ts:72

Get the version number for this object. Each time the object is modified, its version number will be incremented.

Returns ​

number

Revision.

Api ​

Inherited from ​

ts
Map.getRevision

getSize() ​

ts
getSize(): Size | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:695

Get the size of this map.

Returns ​

Size | undefined

The size in pixels of the map in the DOM.

Observable ​

Api ​

Inherited from ​

ts
Map.getSize

getTarget() ​

ts
getTarget(): string | HTMLElement | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:578

Get the target in which this map is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that.

Returns ​

string | HTMLElement | undefined

The Element or id of the Element that the map is rendered in.

Observable ​

Api ​

Inherited from ​

ts
Map.getTarget

getTargetElement() ​

ts
getTargetElement(): HTMLElement;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:586

Get the DOM element into which this map is rendered. In contrast to getTarget this method always return an Element, or null if the map has no target.

Returns ​

HTMLElement

The element that the map is rendered in.

Api ​

Inherited from ​

ts
Map.getTargetElement

getTilePriority() ​

ts
getTilePriority(
   tile, 
   tileSourceKey, 
   tileCenter, 
   tileResolution): number;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:737

Parameters ​

tile ​

Tile

Tile.

tileSourceKey ​

string

Tile source key.

tileCenter ​

Coordinate

Tile center.

tileResolution ​

number

Tile resolution.

Returns ​

number

Tile priority.

Inherited from ​

ts
Map.getTilePriority

getView() ​

ts
getView(): View;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:703

Get the view associated with this map. A view manages properties such as center and resolution.

Returns ​

View

The view that controls this map.

Observable ​

Api ​

Inherited from ​

ts
Map.getView

getViewport() ​

ts
getViewport(): HTMLElement;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:709

Get the element that serves as the map viewport.

Returns ​

HTMLElement

Viewport.

Api ​

Inherited from ​

ts
Map.getViewport

getZoom() ​

ts
getZoom(): number | undefined;

Defined in: packages/core-ol/src/map/gmap.ts:285

获取当前层级

Returns ​

number | undefined


handleBrowserEvent() ​

ts
handleBrowserEvent(browserEvent, type?): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:742

Parameters ​

browserEvent ​

PointerEvent | KeyboardEvent | WheelEvent

Browser event.

type? ​

string

Type.

Returns ​

void

Inherited from ​

ts
Map.handleBrowserEvent

handleMapBrowserEvent() ​

ts
handleMapBrowserEvent(mapBrowserEvent): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:746

Parameters ​

mapBrowserEvent ​

MapBrowserEvent

The event to handle.

Returns ​

void

Inherited from ​

ts
Map.handleMapBrowserEvent

handlePostRender() ​

ts
protected handlePostRender(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:750

Returns ​

void

Inherited from ​

ts
Map.handlePostRender

hasFeatureAtPixel() ​

ts
hasFeatureAtPixel(pixel, options?): boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:545

Detect if features intersect a pixel on the viewport. Layers included in the detection can be configured through the layerFilter option. For polygons without a fill, only the stroke will be used for hit detection. Polygons must have a fill style applied to ensure that pixels inside a polygon are detected. The fill can be transparent.

Parameters ​

pixel ​

Pixel

Pixel.

options? ​

AtPixelOptions

Optional options.

Returns ​

boolean

Is there a feature at the given pixel?

Api ​

Inherited from ​

ts
Map.hasFeatureAtPixel

hasGraphicAtPixel() ​

ts
hasGraphicAtPixel(
   pixel, 
   options?, 
   event?): boolean;

Defined in: packages/core-ol/src/map/gmap.ts:654

判断像素位置是否命中海量点 graphic

Parameters ​

pixel ​

number[]

options? ​
checkWrapped? ​

boolean

hitTolerance? ​

number

layerFilter? ​

(layer) => boolean

event? ​

unknown

Returns ​

boolean


hasListener() ​

ts
hasListener(type?): boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/events/Target.d.ts:75

Parameters ​

type? ​

string

Type. If not provided, true will be returned if this event target has any listeners.

Returns ​

boolean

Has listeners.

Inherited from ​

ts
Map.hasListener

hasProperties() ​

ts
hasProperties(): boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:135

Returns ​

boolean

The object has properties.

Inherited from ​

ts
Map.hasProperties

isInBounds() ​

ts
isInBounds(lonLat): boolean;

Defined in: packages/core-ol/src/map/gmap.ts:332

经纬度点是否在当前视野内

Parameters ​

lonLat ​

Coordinate

Returns ​

boolean


isRendered() ​

ts
isRendered(): boolean;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:778

Returns ​

boolean

Is rendered.

Inherited from ​

ts
Map.isRendered

notify() ​

ts
notify(key, oldValue): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:140

Parameters ​

key ​

string

Key name.

oldValue ​

any

Old value.

Returns ​

void

Inherited from ​

ts
Map.notify

onceInternal() ​

ts
protected onceInternal(type, listener): EventsKey | EventsKey[];

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Observable.d.ts:86

Parameters ​

type ​

string | string[]

Type.

listener ​

(arg0) => unknown

Listener.

Returns ​

EventsKey | EventsKey[]

Event key.

Inherited from ​

ts
Map.onceInternal

onInternal() ​

ts
protected onInternal(type, listener): EventsKey | EventsKey[];

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Observable.d.ts:79

Parameters ​

type ​

string | string[]

Type.

listener ​

(arg0) => unknown

Listener.

Returns ​

EventsKey | EventsKey[]

Event key.

Inherited from ​

ts
Map.onInternal

panTo() ​

ts
panTo(options?): void;

Defined in: packages/core-ol/src/map/gmap.ts:267

平滑移动到指定位置(位置为当前视图投影坐标)

Parameters ​

options? ​

PanToOptions = {}

Returns ​

void


redrawText() ​

ts
redrawText(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:787

Redraws all text after new fonts have loaded

Returns ​

void

Inherited from ​

ts
Map.redrawText

removeBaseLayers() ​

ts
removeBaseLayers(): void;

Defined in: packages/core-ol/src/map/gmap.ts:382

移除全部底图图层

Returns ​

void


removeChangeListener() ​

ts
removeChangeListener(key, listener): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:150

Parameters ​

key ​

string

Key name.

listener ​

Listener

Listener.

Returns ​

void

Inherited from ​

ts
Map.removeChangeListener

removeContentLayers() ​

ts
removeContentLayers(): void;

Defined in: packages/core-ol/src/map/gmap.ts:391

移除全部内容图层(保留底图)

Returns ​

void


removeControl() ​

ts
removeControl(control): Control | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:800

Remove the given control from the map.

Parameters ​

control ​

Control

Control.

Returns ​

Control | undefined

The removed control (or undefined if the control was not found).

Api ​

Inherited from ​

ts
Map.removeControl

removeEventListener() ​

ts
removeEventListener(type, listener): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/events/Target.d.ts:80

Parameters ​

type ​

string

Type.

listener ​

Listener

Listener.

Returns ​

void

Inherited from ​

ts
Map.removeEventListener

removeFeature() ​

ts
removeFeature(feature): void;

Defined in: packages/core-ol/src/map/gmap.ts:503

从所有矢量图层移除要素

Parameters ​

feature ​

Feature

Returns ​

void


removeFeatureById() ​

ts
removeFeatureById(id): void;

Defined in: packages/core-ol/src/map/gmap.ts:513

按 id(属性 id 或 featureId)移除要素

Parameters ​

id ​

string | number

Returns ​

void


removeInfoWindow() ​

ts
removeInfoWindow(overlay): void;

Defined in: packages/core-ol/src/map/gmap.ts:539

移除信息弹窗

Parameters ​

overlay ​

Overlay

Returns ​

void


removeInfoWindowById() ​

ts
removeInfoWindowById(id): void;

Defined in: packages/core-ol/src/map/gmap.ts:544

按 id 移除信息弹窗

Parameters ​

id ​

string | number

Returns ​

void


removeInteraction() ​

ts
removeInteraction(interaction): Interaction | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:808

Remove the given interaction from the map.

Parameters ​

interaction ​

Interaction

Interaction to remove.

Returns ​

Interaction | undefined

The removed interaction (or undefined if the interaction was not found).

Api ​

Inherited from ​

ts
Map.removeInteraction

removeLayer() ​

ts
removeLayer(layer): 
  | BaseLayer<{
[x: string]: any;
}>
  | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:816

Removes the given layer from the map.

Parameters ​

layer ​

BaseLayer<{ [x: string]: any; }>

Layer.

Returns ​

| BaseLayer<{ [x: string]: any; }> | undefined

The removed layer (or undefined if the layer was not found).

Api ​

Inherited from ​

ts
Map.removeLayer

removeLayerById() ​

ts
removeLayerById(id): void;

Defined in: packages/core-ol/src/map/gmap.ts:472

按 id 移除图层

Parameters ​

id ​

string | number

Returns ​

void


removeOverlay() ​

ts
removeOverlay(overlay): Overlay | undefined;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:829

Remove the given overlay from the map.

Parameters ​

overlay ​

Overlay

Overlay.

Returns ​

Overlay | undefined

The removed overlay (or undefined if the overlay was not found).

Api ​

Inherited from ​

ts
Map.removeOverlay

render() ​

ts
render(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:792

Request a map rendering (at the next animation frame).

Returns ​

void

Api ​

Inherited from ​

ts
Map.render

renderSync() ​

ts
renderSync(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:783

Requests an immediate render in a synchronous manner.

Returns ​

void

Api ​

Inherited from ​

ts
Map.renderSync

resetOverview() ​

ts
resetOverview(): void;

Defined in: packages/core-ol/src/map/gmap.ts:413

底图切换后同步鹰眼(视图投影与底图图层)

Returns ​

void


set() ​

ts
set(
   key, 
   value, 
   silent?): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:158

Sets a value.

Parameters ​

key ​

string

Key name.

value ​

any

Value.

silent? ​

boolean

Update without triggering an event.

Returns ​

void

Api ​

Inherited from ​

ts
Map.set

setCenter() ​

ts
setCenter(lonLat): void;

Defined in: packages/core-ol/src/map/gmap.ts:309

设置中心点(WGS-84 经纬度)

Parameters ​

lonLat ​

Coordinate

Returns ​

void


setCursor() ​

ts
setCursor(cursor): void;

Defined in: packages/core-ol/src/map/gmap.ts:344

设置鼠标样式;'default' 视为恢复默认

Parameters ​

cursor ​

string

Returns ​

void


setFullScreen() ​

ts
setFullScreen(fullscreen): void;

Defined in: packages/core-ol/src/map/gmap.ts:359

全屏切换:使用标准 Fullscreen API 对地图容器元素直接进/出全屏, 不依赖 ol FullScreen 控件的私有字段(跨 ol 版本更健壮)。

Parameters ​

fullscreen ​

boolean

Returns ​

void


setLayerGroup() ​

ts
setLayerGroup(layerGroup): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:841

Sets the layergroup of this map.

Parameters ​

layerGroup ​

LayerGroup

A layer group containing the layers in this map.

Returns ​

void

Observable ​

Api ​

Inherited from ​

ts
Map.setLayerGroup

setLayers() ​

ts
setLayers(layers): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:646

Clear any existing layers and add layers to the map.

Parameters ​

layers ​

| BaseLayer<{ [x: string]: any; }>[] | Collection<BaseLayer<{ [x: string]: any; }>>

The layers to be added to the map.

Returns ​

void

Api ​

Inherited from ​

ts
Map.setLayers

setPixelRatio() ​

ts
setPixelRatio(pixelRatio): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:683

Set the pixel ratio of the rendered map.

Parameters ​

pixelRatio ​

number

Pixel ratio.

Returns ​

void

Api ​

Inherited from ​

ts
Map.setPixelRatio

setProperties() ​

ts
setProperties(values, silent?): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:166

Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

Parameters ​

values ​

Partial<NoInfer<Properties>>

Values.

silent? ​

boolean

Update without triggering an event.

Returns ​

void

Api ​

Inherited from ​

ts
Map.setProperties

setSize() ​

ts
setSize(size): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:848

Set the size of this map.

Parameters ​

size ​

Size | undefined

The size in pixels of the map in the DOM.

Returns ​

void

Observable ​

Api ​

Inherited from ​

ts
Map.setSize

setTarget() ​

ts
setTarget(target?): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:859

Set the target element to render this map into. For accessibility (focus and keyboard events for map navigation), the target element must have a properly configured tabindex attribute. If the target element is inside a Shadow DOM, the tabindex atribute must be set on the custom element's host element.

Parameters ​

target? ​

string | HTMLElement

The Element or id of the Element that the map is rendered in.

Returns ​

void

Observable ​

Api ​

Inherited from ​

ts
Map.setTarget

setUserProjection() ​

ts
setUserProjection(proj): void;

Defined in: packages/core-ol/src/map/gmap.ts:351

设置 ol 用户投影(透传 ol/proj.setUserProjection)

Parameters ​

proj ​

string

Returns ​

void


setView() ​

ts
setView(view): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:869

Set the view for this map.

Parameters ​

view ​

View | Promise<ViewOptions> | null

The view that controls this map. It is also possible to pass a promise that resolves to options for constructing a view. This alternative allows view properties to be resolved by sources or other components that load view-related metadata.

Returns ​

void

Observable ​

Api ​

Inherited from ​

ts
Map.setView

setZoom() ​

ts
setZoom(zoom): void;

Defined in: packages/core-ol/src/map/gmap.ts:290

设置当前层级

Parameters ​

zoom ​

number

Returns ​

void


setZoomAndCenter() ​

ts
setZoomAndCenter(zoom, lonLat): void;

Defined in: packages/core-ol/src/map/gmap.ts:316

同时设置层级与中心点(经纬度)

Parameters ​

zoom ​

number

lonLat ​

Coordinate

Returns ​

void


showTraffic() ​

ts
showTraffic(visible, opts?): void;

Defined in: packages/core-ol/src/map/gmap.ts:572

显隐实时路况图层;首次调用时自动创建(默认百度路况、动态刷新)。

Parameters ​

visible ​

boolean

opts? ​
isDynamic? ​

boolean

origin? ​

"GD" | "BD"

Returns ​

void


switchBase() ​

ts
switchBase(reference, config?): void;

Defined in: packages/core-ol/src/map/gmap.ts:405

切换底图(必要时切换视图投影并重投影既有图层/overlay)

Parameters ​

reference ​

BaseLayerReference

config? ​

BaseLayerConfig

Returns ​

void


unEventByKey() ​

ts
unEventByKey(key): void;

Defined in: packages/core-ol/src/map/gmap.ts:552

解绑通过 on/once 注册的监听

Parameters ​

key ​

EventsKey | EventsKey[]

Returns ​

void


unInternal() ​

ts
protected unInternal(type, listener): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Observable.d.ts:93

Unlisten for a certain type of event.

Parameters ​

type ​

string | string[]

Type.

listener ​

(arg0) => unknown

Listener.

Returns ​

void

Inherited from ​

ts
Map.unInternal

unset() ​

ts
unset(key, silent?): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Object.d.ts:179

Unsets a property.

Parameters ​

key ​

string

Key name.

silent? ​

boolean

Unset without triggering an event.

Returns ​

void

Api ​

Inherited from ​

ts
Map.unset

updateSize() ​

ts
updateSize(): void;

Defined in: node_modules/.pnpm/ol@10.9.0/node_modules/ol/Map.d.ts:875

Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport.

Returns ​

void

Api ​

Inherited from ​

ts
Map.updateSize