I found a kind of hack to perform an arbitrary action on tapping on the Marker. (1)Keep the popup, but have it's contents do whatever you like (e.g. Open a modal by defaut) and (2) Hide the popup's container div with CSS.
In my case it looked like this:
Map View, remains unchanged:
<Marker position={[item.lat, item.lng]} key={item.machineid}>
<Popup maxWidth={720}>
<ItemGrid machineid={item.machineid}
username={this.props.username}/>
</Popup>
</Marker>
Then ItemGrid which was previously in a pop changes to include a modal. (Here we are using reactstrap components and set the modal to true
whnn the component mounts.) :
class ItemGrid extends Component {
constructor(props){
super(props);
this.state = {modal:false}
this.toggle = this.toggle.bind(this);
}
toggle() {
this.setState({
modal: !this.state.modal
});
}
componentDidMount() {
this.setState({modal:true})
}
render() {
return (
<div>
<Modal isOpen={this.state.modal} toggle={this.toggle} className={this.props.className}>
<ModalHeader toggle={this.toggle}>Modal Header</ModalHeader>
<ModalBody>
{ContentThatWasPreviouslyInPopup}
</ModalBody>
</Modal>
</div>
And Finally in leaflet CSS:
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
padding: 8px 8px 0 0;
text-align: center;
width: 0px;
height: 0px;
font: 0px/0px Tahoma, Verdana, sans-serif; //DANGEROUS HACK
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
width: 0px // DANGEROUS HACK
}