Disable click event on marker in mapbox - leaflet

I am creating a poi create task with mapbox map, The marker should move to the new position if the click event is occurring on map. The marker will initially be placed on the map at a default position. I want to disable the click event when it is clicking on the marker, It is working fine for the initial marker( clickable: false) option, For the dynamically added markers this option is not working
tMarker = L.marker(
new (L.LatLng)(latitude,longitude),{
clickable: false
}
)

Related

How to prevent openning a popup when you choose a layer to show in leaflet?

I'm a working on a project with leaflet where a it shows three layer
you can enable o disable whenever you want to display all the markers from that layer.
Every marker has a popup that it opens when you click on the marker
The problema i have is that when you hit over on any layer and active it, the marker displays its popup.
Is there any way to not open it when you activate a layer? o at least to keep it close and just open when you click on it?
Thanks colleagues!
I revised the solution to instead target layer activation.
This will programmatically unbind popup from each marker in the layer, hence preventing popups from opening when layer is activated.
var layerGroup = L.layerGroup().addTo(map);
layerGroup.on("layeradd", function (event) {
event.layer.eachLayer(function (marker) {
marker.unbindPopup();
});
});

Need to disable deleting a marker layer in leaflet

I am working with a leaflet map that uses a custom image, draws rectangles on it with markers and tooltips at the center of each rectangle.
It includes a toolbar that sets a delete mode. In the delete mode, the click event on the rectangle changes the rectangle color and adds it to a list to delete. But the rectangle is not deleted.
However, the markers are deleted when clicked on. How do I disable this deletion?
I searched the Leaflet documentation looking for an option to disable deleting the marker: I couldn't find one.
Debugging in the browser, I see that after the handler I added for the onclick event on the marker, another handler is executed in leaflet that deletes the marker.
I've pored over the configuration settings for the map, but don't see where the delete is disabled for the rectangles.

React leaflet adding layer that covers whole map and accepts leaflet mouse events

I have many markers on map with event listeners added to them. I also have a control on map that enables placing other shapes (circles) when map is clicked in the position of a click. The problem now is that clicking on position on the map where marker placed when control is enabled also triggers marker click event. Is there a solution in react-leaflet to add some pane on top of all other panes and layers so events are triggered only on that pane. The key thing here is that pane itself does not have leaflet event handlers, hence can not pass latLng to event callback. It only provides DOM mouseEvent but not LeafletMouseEvent that I need.

How to keep a popup visible if show popup is on hover, not click. It hides as soon as you leave the marker

I am using clustering, and when the mouse hovers over one cluster it shows a popup.
The user needs to click on a link on that popup.
But as soon as the mouse leaves the marker, the popup closes.
What's an easy way to do this?
I've read and found there is this mousemove event, but i'm afraid that will be triggered many times and slow things down.
map.on('mousein ', 'clusters', function (e) {
var coordinates = e.features[0].geometry.coordinates.slice();
var id = e.features[0].id;
map.getSource('users').getClusterLeaves(id, 50, 0, function(error, features){
const html = features
new mapboxgl.Popup()
.setLngLat(coordinates)
.setHTML(html)
.addTo(map);
})
});
Right now, it hides the popup as soon as you leave the marker.
I want the popup to be shown if user hover over marker and corresponding popup.

How to deselect a marker in google maps swift

Im trying to deselect a maker that I selected using mapView.selectedMarker = locationMarker. When I use mapView.clear() my map is clear but when I tap to open the marker at the same location I have to tap twice because I never did deselect the marker. I can not find the function that deselect the marker.
According to doc written at GMSMapView's property selectedMarker, it says
You just need to write mapView.selectedMarker = nil to deselect the selected marker.