Class Marker

L.Class powers the OOP facilities of Leaflet and is used to create almost all of the Leaflet classes documented.

Hierarchy

Index

Constructor methods

Methods

Constructor methods

constructor(latlng: LatLng, options?: MarkerOptions): Marker

Instantiates a Marker object given a geographical point and optionally an options object.

Parameters

Returns

Marker

Methods

public addEventListener(type: string, fn: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn: (e: L.LeafletEvent) => void
  • context?: any optional

Returns

Marker

public addEventListener(eventMap: any, context?: any): Marker

Parameters

  • eventMap: any
  • context?: any optional

Returns

Marker

public addOneTimeEventListener(type: string, fn: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn: (e: L.LeafletEvent) => void
  • context?: any optional

Returns

Marker

public addTo(map: Map): Marker

Adds the marker to the map.

Parameters

Returns

Marker

public bindPopup(html: string, options?: PopupOptions): Marker

Binds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.

Parameters

Returns

Marker

public bindPopup(el: HTMLElement, options?: PopupOptions): Marker

Binds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.

Parameters

Returns

Marker

public bindPopup(popup: Popup, options?: PopupOptions): Marker

Binds a popup with a particular HTML content to a click on this marker. You can also open the bound popup with the Marker openPopup method.

Parameters

Returns

Marker

public clearAllEventListeners(): Marker

Returns

Marker

public closePopup(): Marker

Closes the bound popup of the marker if it's opened.

Returns

Marker

public fire(type: string, data?: any): Marker

Parameters

  • type: string
  • data?: any optional

Returns

Marker

public fireEvent(type: string, data?: any): Marker

Parameters

  • type: string
  • data?: any optional

Returns

Marker

public getLatLng(): LatLng

Returns the current geographical position of the marker.

Returns

LatLng

public hasEventListeners(type: string): boolean

Parameters

  • type: string

Returns

boolean

public off(type: string, fn?: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn?: (e: L.LeafletEvent) => void optional
  • context?: any optional

Returns

Marker

public off(eventMap?: any, context?: any): Marker

Parameters

  • eventMap?: any optional
  • context?: any optional

Returns

Marker

public on(type: string, fn: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn: (e: L.LeafletEvent) => void
  • context?: any optional

Returns

Marker

public on(eventMap: any, context?: any): Marker

Parameters

  • eventMap: any
  • context?: any optional

Returns

Marker

public onAdd(map: Map)

Should contain code that creates DOM elements for the overlay, adds them to map panes where they should belong and puts listeners on relevant map events. Called on map.addLayer(layer).

Parameters

public onRemove(map: Map)

Should contain all clean up code that removes the overlay's elements from the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).

Parameters

public once(type: string, fn: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn: (e: L.LeafletEvent) => void
  • context?: any optional

Returns

Marker

public openPopup(): Marker

Opens the popup previously bound by the bindPopup method.

Returns

Marker

public removeEventListener(type: string, fn?: (e: L.LeafletEvent) => void, context?: any): Marker

Parameters

  • type: string
  • fn?: (e: L.LeafletEvent) => void optional
  • context?: any optional

Returns

Marker

public removeEventListener(eventMap?: any, context?: any): Marker

Parameters

  • eventMap?: any optional
  • context?: any optional

Returns

Marker

public setIcon(icon: Icon): Marker

Changes the marker icon.

Parameters

Returns

Marker

public setLatLng(latlng: LatLng): Marker

Changes the marker position to the given point.

Parameters

Returns

Marker

public setOpacity(opacity: number): Marker

Changes the opacity of the marker.

Parameters

  • opacity: number

Returns

Marker

public setPopupContent(html: string, options?: PopupOptions): Marker

Sets an HTML content of the popup of this marker.

Parameters

Returns

Marker

public setPopupContent(el: HTMLElement, options?: PopupOptions): Marker

Sets an HTML content of the popup of this marker.

Parameters

Returns

Marker

public setZIndexOffset(offset: number): Marker

Changes the zIndex offset of the marker.

Parameters

  • offset: number

Returns

Marker

public toGeoJSON(popup: Popup, options?: PopupOptions): any

Returns a GeoJSON representation of the marker (GeoJSON Point Feature).

Parameters

Returns

any

public togglePopup(): Marker

Toggles the popup previously bound by the bindPopup method.

Returns

Marker

public unbindPopup(): Marker

Unbinds the popup previously bound to the marker with bindPopup.

Returns

Marker

public update(): Marker

Updates the marker position, useful if coordinates of its latLng object were changed directly.

Returns

Marker