LogoLogo
CMSGitHubSupportBook a demo
  • Documentation
  • Academy
  • Help Center
  • Welcome
  • SDKS & Frameworks
    • Web
      • Getting Started
        • Prerequisites
          • MapsIndoors
          • Map Engine Provider
            • Option 1: Get your Mapbox Access Token
            • Option 2: Get your Google Maps API Keys​
          • Map Engine Setup
        • Getting Started: MapsIndoors
      • Map Visualization
        • Highlight, Hover and Select
        • Remove Labels from Buildings and Venues
        • Change Building Outline
        • Managing Collisions Based on Zoom Level
        • 3D Maps
          • Managing your 3D Maps
        • Base Map Styling - Google Maps
        • Managing feature visibility for Mapbox
      • Wayfinding
        • Directions
        • Directions Service
          • Tailoring the directions to your specific needs
        • Directions Renderer
          • Customizing the Route Animation
        • Multi-stop navigation
          • Custom Icons
        • User's Location as Point of Origin
      • Search
        • Search Operations
        • Searching
        • Using External ID, Geospatial Joins
        • Utilizing MapsIndoors Web Components and Other Searches
      • Map Management
      • Data Visualization
        • Display Heatmap Overlay
      • Other guides
        • Authentication
          • Single Sign-On
            • SSO Configuration
            • SSO Authorisation
          • 2-Factor Authentication
          • Password Reset
        • Application User Roles
        • Custom Properties
        • Display Language
        • Language
        • User Positioning
          • Show User's Location aka. Blue Dot
          • Using Cisco DNA Spaces
        • Working with Events
        • Turn Off Collisions Based on Zoom Level
        • Remove Labels from Buildings and Venues for Web
        • Synchronizing data for a subset of venues
        • Custom Floor Selector
      • Display Rules in Practice
      • Offline Data
      • Managing map visibility
    • Android
      • Getting Started
        • Prerequisites
        • Create a New Project
        • Show a Map
        • Create a Search Experience
        • Getting Directions
        • Enable Live Data
        • Integrating MapsIndoors into your own App
        • Migrating from V3 to V4
          • Migrating to Mapbox V11
      • Directions
        • Directions Service
        • Directions Renderer
          • User's Location as Point of Origin
        • Wayfinding Instructions
          • See Route Element Details
        • Using multi-stop navigation
      • Searching
        • Searching on a Map
        • Creating a Search Experience
      • Switching Solutions
      • Caching & Offline Data
      • Display Language
      • Displaying Objects
        • Application User Roles
        • Getting a Polygon from a Location
        • Location Clustering
        • Location Data Sources
        • Location Details
        • Turn Off Collisions Based on Zoom Level
        • Enabling and Disabling features on the map
      • Change Building Outline Color
      • Event Logging
      • Configuring a menu with AppConfig
      • Display Heatmap Overlay
      • Custom Properties
      • Custom Floor Selector
      • External IDs
      • User Positioning
        • Show User's Location aka. Blue Dot
        • Using Cisco DNA Spaces
        • Using Google Fused Location Provider
        • Using Indoor Atlas
      • Authentication
        • Single Sign-On
          • SSO Configuration
          • SSO Authorisation
        • 2-Factor Authentication
        • Password Reset
      • Display Rules in Practice
        • Label styling through Display Rules
      • Highlight and Select
    • iOS
      • Getting Started
        • Prerequisites
        • Set Up Your Environment
        • Display a Map
        • Search
        • Getting Directions
        • Migrating from v3 to v4
      • Directions
        • Directions Renderer
          • User's Location as Point of Origin
        • Wayfinding Instructions
          • See Route Element Details
        • Directions Service
        • Using multi-stop navigation
      • Searching
        • Searching on a Map
        • Creating a Search Experience
      • Caching & Offline Data
      • Displaying Objects
        • Application User Roles
        • Getting a Polygon from a Location
        • Location Details
        • Turn Off Collisions Based on Zoom Level
        • Enabling and Disabling features on the map
      • Custom Floor Selector
      • Change Building Outline Color
      • Custom Map Padding
      • Custom Properties
      • Display Rules in Practice
        • Label styling through Display Rules
      • Switching Solutions
      • Show User's Location aka. Blue Dot
        • Using Indoor Atlas
        • Using Cisco DNA Spaces
      • Highlight and Select
      • Display Language
    • React Native
      • Getting Started
        • Prerequisites
        • Project Setup
        • Displaying a Map
        • Creating a Search Experience
        • Getting Directions
        • Enabling Live Data
      • Showing Blue Dot
    • Flutter
      • Getting Started
        • Prerequisites
        • Create a New Project
        • Show a Map
        • Create a Search Experience
        • Getting Directions
      • Migration Guide
    • Integration API
      • Integration API Access
        • Access with Swagger
        • Access with Postman
        • Access with Python
        • Client credentials flow
      • Data Description
      • Reverse Geocoding
      • Route Access
      • OpenAPI Specification
    • Built-In Map Edits
      • Getting started
      • Authentication
      • Release notes
      • Reference docs
  • Products
    • Product Overview
    • CMS
      • Interface Overview
      • Display Rules
      • Media Library
        • 2D Models and Icons
        • 3D Models
      • Editing Data
      • Solution Settings
      • Settings
      • Data Concepts
      • User Roles
      • Route Network
        • Barrier Route Element
        • Door Route Element
      • Additional Location Details
    • Map Template
      • Getting Started
        • Web Component
        • React Component
      • Configuration
        • Query Parameters
      • Customization
      • Deploying Map Template to a cloud storage provider
      • 2D/3D Visibility Switch
      • External customization of the Map Template
      • Location Details configuration
      • Kiosk
        • QR code configuration
  • Other
    • Design
      • Standard MapsIndoors Map Style
      • Using a Custom Mapbox MapStyle
    • Changelog
      • Web SDK
        • V4
        • V3
      • Android SDK
        • V4
        • V3
      • iOS SDK
        • V4
        • V3
      • React Native SDK
      • Flutter SDK
      • MI Components
      • Map Template
    • Glossary
  • Legacy Docs
    • Android SDK V3
      • Getting Started
        • Prerequisites
        • Create a New Project
        • Show a Map
        • Create a Search Experience
        • Getting Directions
        • Enable Live Data
        • Integrating MapsIndoors into your own App
    • iOS SDK V3
      • Getting Started
        • Prerequisites
        • Set Up Your Environment
        • Display a Map
        • Search
        • Directions
        • Live Data
        • Integrating MapsIndoors into your own App
      • Inspect Route Element for iOS v3
      • Using Cisco DNA Spaces
      • Using Indoor Atlas
      • Switching Solutions
      • Show User's Location aka. Blue Dot
      • Application User Roles
      • Getting a Polygon from a Location
      • Location Details
  • MapsIndoors SDK Firewall
  • Google Analytics & Logging
  • Reference Docs
    • Web SDK
    • Android SDK
    • iOS SDK
    • React Native SDK
    • Flutter SDK
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. SDKS & Frameworks
  2. Web
  3. Data Visualization
  4. Live Data

BadgeRenderer

Last updated 11 months ago

Was this helpful?

The BadgeRenderer class is used and exposed by the Web SDK. Internally, it is used to visualize live data updates for different locations. Based on the type of live data updates we receive for a location, the badge may look different. The following example showcases the style of badge temperature updates.

Customize the BadgeRenderer

Following the next example will allow you to update a location's icon with a custom badge.

  1. Create a new instance of our BadgeRenderer class providing a config optionally including the following properties:

Name
Type
Description
Default Value

backgroundColor

string

The background color of the badge.

#1E2025

fontFamily

string

The font family is used for the text inside the badge.

'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"

fontSize

string

The font size used for the text inside the badge.

14px

fontWeight

string

The font-weight used for the text inside the badge.

bold

position

string

The position of the badge in relation to the icon. Options are: top_left, top_right, bottom_right, bottom_left. Please note that other badges may overlap. E.g. the highlight badge is on the top left corner of the icon.

bottom_left

size

object

The size of the badge. { width: number, height: number }

null

strokeColor

string

The color of the outline of the badge.

null

strokeWidth

string

The width of the outline of the badge.

0

text

string

The text inside the badge.

null

textColor

string

The color of the text inside the badge.

#FCFCFC

const badgeRenderer = new mapsindoors.BadgeRenderer({
  backgroundColor: '#FF69B4',
  fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
  fontSize: '15px',
  fontWeight: 'bold',
  position: 'bottom_right',
  size: { width: 50, height: 50 },
  strokeColor: '#0078FE',
  strokeWidth: 2,
  text: 'Default Badge Text',
  textColor: '#FFFFFF'
});
  1. Get the location's icon as an Image instance. You can use the MapsIndoors instance for this.

const mapsIndoorsInstance = new mapsindoors.MapsIndoors({ ... });
const statefulDisplayRule = mapsIndoorsInstance.getStatefulDisplayRule([LOCATION_ID], true);
const icon = await statefulDisplayRule.getIcon(); 
  1. Invoke the overlay method on the badgeRenderer object. The overlay method takes 2 parameters.

    • image - the image you want to modify. Please make sure that it is an instance of Image and not just a simple string URL.

    • custom settings - This parameter offers the flexibility to override and tailor the badge configuration according to your specific requirements, thereby allowing customization beyond the default settings established during the instantiation of a new instance of the BadgeRenderer. You have the option to customize any of the properties described above for the BadgeRenderer class.

const newIcon = await badgeRenderer.overlay(
    icon, 
    {
        text: 'New Badge Text',
        textColor: '#000000'
    }
);
  1. Set the a new Display Rule for your location.

const newDisplayRule = { icon: newIcon };
mi.setDisplayRule([LOCATION_ID], newDisplayRule);

<!-- index.html -->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>MapsIndoors</title>
  <script src="https://app.mapsindoors.com/mapsindoors/js/sdk/4.33.0/mapsindoors-4.33.0.js.gz?apikey=YOUR_MAPSINDOORS_API_KEY"></script>
  <script src='https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.js'></script>
  <link href='https://api.mapbox.com/mapbox-gl-js/v2.14.1/mapbox-gl.css' rel='stylesheet' />
</head>

<body>
  <div id="map" style="width: 600px; height: 600px;"></div>
  
  <script>
    const mapViewInstance = new mapsindoors.mapView.MapboxView({
        accessToken: YOUR_ACCESS_TOKEN,
        element: document.getElementById('map'),
        center: { lat: 38.8974905, lng: -77.0362723 }, // The White House
        zoom: 17,
        maxZoom: 22
    });
    
    const mapsIndoorsInstance = new mapsindoors.MapsIndoors({
        mapView: mapViewInstance
    });
    
    const badgeRenderer = new mapsindoors.BadgeRenderer({
        backgroundColor: '#FF69B4',
        fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
        fontSize: '15px',
        fontWeight: 'bold',
        position: 'bottom_right',
        size: { width: 50, height: 50 },
        strokeColor: '#0078FE',
        strokeWidth: 2,
        text: 'Default Badge Text',
        textColor: '#FFFFFF'
    });
    
    mapsIndoorsInstance.on('click', async function (location) {
        const statefulDisplayRule = mapsIndoorsInstance.getStatefulDisplayRule(location, true);
        const icon = await statefulDisplayRule.getIcon();

        const newIcon = await badgeRenderer.overlay(
            icon,
            {
                text: 'New Badge Text',
                textColor: '#000000'
            }
        );

        const displayRuleOverrides = {
            icon: newIcon,
            iconSize: { width: 150, height: 150 }
        };
        
        mapsIndoorsInstance.setDisplayRule(location.id, displayRuleOverrides);
    });
  </script>
</body>
</html>

Since the BadgeRenderer is a public class, you have the option to customize and make use of it in your own application. ()

class definition