Instance Members

getId()

Get the marker's id.

// one marker 
marker.getId();

// markers
let ids = [];
for(let i = 0; i < markers.length; i++) {
    ids.push(markers[i].getId());
}
console.log('Ids :', ids);

setLngLat(markerId, lnglat)

Set the marker's geographical position and move it.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

lnglat

Latitude and longitude {lat, lng}

Object

const lnglat = { lat: 37.482630, lng: 126.899893};
marker.setLngLat(markerID, lnglat);

getLngLat(markerId)

Get the marker's geographical location.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

const lnglat = marker.getLngLat(markerID);
console.log(lnglat);

setMessage(markerId, message)

Sets the popup's content to a string of text.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

message

The message you want to show on the marker.

HTML

const message = <div>Change Message</div>; 
marker.setMessage(id, message);

setZIndex(markerId, index)

Change the marker's Z-lndex.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

index

The z-index CSS property sets the z-order of a positioned element and its descendants or flex items.

Numeric

marker.setZIndex(markerID, index);

getZIndex(markerId)

Get the marker's Z-lndex.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

marker.getZIndex(markerID);

setOffset(markerId, offset)

Sets the offset of the marker.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

offset

Move the selected element to a specific location.

Array<Numeric>

const offset = [0, -20]; 
marker.setOffset(markerID, offset);

getOffset(markerId)

Get the marker's offset.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

marker.getOffset(markerID);

setDraggable(markerId, bool)

Sets the draggble property and functionality of the marker.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

bool

Whether to move by clicking on the marker.

boolean

const bool = true;
marker.setDraggable(markerID, bool);

isDraggable(markerId)

Returns true if the marker can be dragged.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

marker.isDraggable(markerID);

setPopupOffset(markerId, offset)

Sets the Popup offset of the marker.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

offset

Move the selected element to a specific location.

Array<Numeric>

const offset = [0, -20]; 
marker.setPopupOffset(markerID, offset);

getPopupOffset(markerId)

Get the marker's Popup offset.

Required Parameter
Description
Type

markerID

The ID that created the marker.

String

marker.getPopupOffset(markerID)

togglePopup()

Opens or closes the Popup instance that is bound to the Marker, depending on the current state of the Popup.

// marker
marker.togglePopup();

// markers
markers[i].togglePopup();

Last updated