popup with multiple points features

前端 未结 1 1345
醉话见心
醉话见心 2021-01-25 21:14

i\'m having some troubles with open layer 5 looking/coping this example https://openlayers.org/en/latest/examples/icon.html?q=marker

having more than one \"clickable ic

相关标签:
1条回答
  • 2021-01-25 21:18

    You need to destroy the old popup before creating a new one. But there may be a problem with destroy followed immediately by recreate, see Bootstrap popover destroy & recreate works only every second time so you may need a short timeout and the update to the relevant code in the example would look like

        if (feature) {
          $(element).popover('destroy');
          setTimeout(function () {
            var coordinates = feature.getGeometry().getCoordinates();
            popup.setPosition(coordinates);
            $(element).popover({
              'placement': 'top',
              'html': true,
              'content': feature.get('name')
            });
            $(element).popover('show');
          }, 200);
        } else {
          $(element).popover('destroy');
        }
    

    or you could try a solution based one of the other answers in that question

    0 讨论(0)
提交回复
热议问题