DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

Vue Vector Map - Floor Plan

This demo illustrates how you can use custom data in the VectorMap component. Visualized, the custom data constitutes a floor plan.

Backend API
<template> <DxVectorMap id="vector-map" :max-zoom-factor="4" :projection="projection" > <DxLayer :data-source="buildingData" :hover-enabled="false" name="building" /> <DxLayer :data-source="roomsData" :border-width="1" name="rooms" color="transparent" > <DxLabel :enabled="true" data-field="name" /> </DxLayer> <DxTooltip :enabled="true" :customize-tooltip="customizeTooltip" /> </DxVectorMap> </template> <script setup lang="ts"> import { DxVectorMap, DxLayer, DxLabel, DxTooltip, } from 'devextreme-vue/vector-map'; import { roomsData, buildingData } from './data.ts'; const projection = { to: ([l, lt]: [number, number]) => [l / 100, lt / 100], from: ([x, y]: [number, number]) => [x * 100, y * 100], }; const customizeTooltip = (info: any) => (info.layer.name === 'rooms' ? { text: `Square: ${info.attribute('square')} ft&#178` } : {}); </script> <style> #vector-map { height: 400px; } </style>
export const buildingData = { type: 'FeatureCollection', features: [ { type: 'Feature', geometry: { type: 'Polygon', coordinates: [[ [10, -80], [-80, -80], [-80, 80], [40, 80], [40, -20], [100, -20], [100, -80], [30, -80], [30, -74], [34, -74], [34, -68], [40, -68], [40, -74], [94, -74], [94, -26], [40, -26], [40, -60], [34, -60], [34, 74], [-74, 74], [-74, 30], [10, 30], [10, 24], [-74, 24], [-74, -24], [10, -24], [10, -30], [-74, -30], [-74, -74], [10, -74], ]], }, }, ], }; export const roomsData = { type: 'FeatureCollection', features: [ { type: 'Feature', properties: { name: 'Room 1', square: 576, }, geometry: { type: 'Polygon', coordinates: [[ [-74, -30], [34, -30], [34, -74], [-74, -74], ]], }, }, { type: 'Feature', properties: { name: 'Room 2', square: 600, }, geometry: { type: 'Polygon', coordinates: [[ [-74, 24], [34, 24], [34, -24], [-74, -24], ]], }, }, { type: 'Feature', properties: { name: 'Room 3', square: 540, }, geometry: { type: 'Polygon', coordinates: [[ [-74, 74], [34, 74], [34, 30], [-74, 30], ]], }, }, { type: 'Feature', properties: { name: 'Room 4', square: 288, }, geometry: { type: 'Polygon', coordinates: [[ [40, -26], [94, -26], [94, -74], [40, -74], ]], }, }, ], };
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app');
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="./bundle.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> <script src="bundles/vendor/vue.vendor.js"></script> <script src="./bundle.js"></script> </body> </html>