React Leaflet: Show Popup

Could anyone use the Popup React Leaflet Popup element to display the popup on mouse rather than click?

I cannot find a way to achieve this.

+3


source to share


1 answer


I recently solved this problem using React Refs and the Elevator API .

Barebones example:



import React, { Component } from 'react';

import { Circle } from 'react-leaflet';

class Foo extends Component {
    render() {
        const { center, radius } = this.props;
        return (
            <Circle
              ref={circle => { this.circle = circle; }}
              center={center}
              radius={radius}
              onMouseOver={() => {
                  this.circle.leafletElement.bindPopup('foo').openPopup();
              }}/>
        );
    }
}

export default Foo;

      

+1


source







All Articles