Search code examples
javascriptimagepopupopenlayers

Add images in popup feature of ol-ext (OpenLayers)


I am trying to add images within the popup feature of ol-ext (OpenLayers) available at https://github.com/Viglino/ol-ext/blob/master/examples/popup/map.popup.feature.html

Any workarounds on how to either add images below the popup or within it? I have already asked for it to be added as a feature at the official repository.


Solution

  • You are displaying data in an HTML table so to display an image you would need the necessary HTML to construct an image - in the case of the example you could show the department flag by using its id in the url for the image src. The source I am using has flags for most, but not all, French departments

          'id': {
            title: 'Flag',  // attribute's title
            before: '<img src="https://www.crwflags.com/fotw/images/f/fr-',
            after: '.gif">'
           }