As per the CARTO docs I am using the following code to trigger a info pop up when the user's mouse hovers over a feature:

const popup = L.popup({ closeButton: false });
    ecosystem.on(carto.layer.events.FEATURE_OVER, featureEvent => {
      if (!popup.isOpen()) {

However, the info pop up doesn't close when the user's mouse is moved out of the feature's bounds. The user has to click for the windows to close. Is it possible for the info pop up to only display when the mouse hovers over the feature, and closes automatically?

Here is a working example.


You are only attaching a handler for the featureOver event, but not to the featureOut. If you check the example at the end where events are assigned:

  function setPopupsHover() {
    populatedPlacesLayer.on('featureOver', openPopup);
    populatedPlacesLayer.on('featureOut', closePopup);

I also recommend you to update to the last version of CARTO.js.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.