Marker

Marker manipulation

Marker

Creates a marker on the map using the specified option. To display markers, you can set coordinate value, marker icons, and icon sizes.

new fatosmap.maps.Marker({ option });

Parameter

anchor, offset, closeButton, and closeOnClick are available only if the popup message is set.

Example

** Single Create Marker **
let marker = new fatosmap.maps.Marker({
        position: {lat: 37.564895, lng: 126.987056},
        map: mapInstance,
        icon: image(My Image),
        iconSize: [30, 30],
        message: 'Fatos', // String
        //message: `<div>FATOS</div>`, // HTML 
        label: `<div>1</div>`, //HTML
        anchor : 'bottom',
        markerOffset : [0, 0],
        popupOffset: [0,0],
        closeButton: true,
        closeOnClick: true,
        drag: true,
        addMarkerEvent: [
                {
                    event:'dragstart',
                    callback: onDragStart
                },
                {
                    event:'drag',
                    callback: onDrag
                },
                {
                    event:'dragend',
                    callback: onDragEnd
                }
            ]
});
function onDragStart(e) {
    console.log('onDragStart', e);
}
function onDrag(e) {
    console.log('onDrag', e);
}
function onDragEnd  (e) {
    console.log('Dragend', e);
};
---------------------------------------------------------------------------
** Multi Create Markers **
let markers = [];
let positions = [
        { lat: 37.564952 , lng: 125.987321 },
        { lat: 37.564952 , lng: 126.987321 },
        { lat: 37.564952 , lng: 124.987321 }
];

for(let i = 0; i < positions.length; i++){
        let marker = new fatosmap.maps.Marker({
                position: positions[i],
                map: mapInstance
        })
        markers.push(marker)
        markers[i].setMap(mapInstance)
    }

RemoveMarker

Clears the markers shown on the map.

Example

marker.setMap(null);

Last updated