Skip to main content Skip to footer

Overlay a Custom Banner on Top of FlexMap in React

FlexMap with custom banner overlayed

Background:

In some scenarios, you may want to display a notification, warning, or status message over a FlexMap component, such as a maintenance notice or informational banner. Since the map is rendered inside a container, you can layer a banner over the map using plain HTML and CSS without interfering with the map’s interactivity.

Steps to Complete:

  1. Wrap the FlexMap component in a container <div>.
  2. Insert a banner element above the FlexMap component in the markup.
  3. Use CSS to position and style the banner for correct overlay behavior.

Getting Started:

Wrap the FlexMap component in a container <div>

The container gives you a common positioned parent to place the banner in relation to the map. By giving the container position: relative, you can absolutely position the banner inside it on top of the map.

<div className="map-wrapper">
 

  <FlexMap
    source={mapSource}
    binding="name"
    style={{ height: 600, width: '100%' }}
  />
</div>
  • The .map-wrapper div contains the overlay banner and the FlexMap.

 

Insert a banner element above the FlexMap component in the markup

<div className="map-wrapper">
  <div className="map-banner">
    ⚠️ Map is in read-only mode due to maintenance
  </div>

  <FlexMap
    source={mapSource}
    binding="name"
    style={{ height: 600, width: '100%' }}
  />
</div>
  • By placing the banner before the map element in the DOM, you ensure it sits above the map visually.

 

Use CSS to position and style the banner for correct overlay behavior

The CSS below positions the banner absolutely inside the relatively positioned wrapper. You can adjust values like top, background, or zIndex as needed.

.map-wrapper {
  position: relative;
}

.map-banner {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fffbe6;
  border: 1px solid #999;
  border-radius: 5px;
  padding: 10px 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  font-weight: bold;
}
  •  position: relative on the wrapper lets the banner be positioned above the map.
  • z-index: 1000 ensures the banner sits on top of the FlexMap’s canvas.
  • The FlexMap component remains fully functional underneath the banner because the banner does not consume pointer events unless you choose to.

 

With this React setup, you can overlay a banner on top of the FlexMap component that stays positioned correctly and can convey important status or informational messages without interfering with the map’s functionality.

Happy coding!

Andrew Peterson

Technical Engagement Engineer