Skip to content

Custom control to add tooltip to feature #918

Discussion options

You must be logged in to vote

I suggest you to add the event directly to the layer instead to the group:

  const addTooltip = (e)=>{
    var layer = e.target;
    layer.bindTooltip('TEST',{permanent: true}).openTooltip();
  };

  const afterClick  = (e, obj)=>{
    if (obj.button._button.toggleStatus) {
      map.pm.getGeomanLayers().forEach((layer)=>{
        layer.on('click', addTooltip);
      })
    } else {
      map.pm.getGeomanLayers().forEach((layer)=>{
        layer.off('click', addTooltip);
        layer.unbindTooltip(); // remove existing tooltips
      })
    }
  };

  map.pm.Toolbar.createCustomControl({name: 'test', afterClick});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cannibalflea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants