Recommand · December 8, 2021 0

Can not set maxPoint when draw a point in Openlayers

I am drawing a point to get its coordinate but maxPoints on Draw doesn’t work

$("#track-manual").click(()=>{
    const manualSource = new ol.source.Vector();
    const manualLocation = new ol.layer.Vector({
        source: manualSource,
        style: new ol.style.Style({
            image: new ol.style.Circle({
                radius: 7,
                fill: new ol.style.Fill({
                    color: 'red',
                })
            })
        })
    })
    interviewMap.addLayer(manualLocation);
    
    const addManualLocation = new ol.interaction.Modify({ source: manualSource });
    interviewMap.addInteraction(addManualLocation);
    let draw, snap;
    function addInteractions() {
        draw = new ol.interaction.Draw({
            source: manualSource,
            type: 'Point',
            maxPoints: 1,
        }),
            interviewMap.addInteraction(draw);
        snap = new ol.interaction.Snap({ source: manualSource });
        interviewMap.addInteraction(snap);
    
    }
    
    addInteractions();
})