@kong-ui-public/analytics-geo-map
@kong-ui-public/analytics-geo-map
This Vue component provides a geographical map visualization based on maplibre-gl and displays country metrics using color-coded layers. It supports dynamic updates to country metrics and allows focusing on specific countries.
Renders provided GeoJSON data into a choropleth style map.
Features
- Interactive geographical map visualization using
maplibre-gl. - Color-coded countries based on provided metrics.
- Tooltips showing country names and their corresponding metrics.
- Ability to focus on specific countries with customizable bounds.
- Dynamic updates to country metrics and map features.
Requirements
vuemust be initialized in the host application.maplibre-glmust be added as adependencyin the host application. See here- GeoJSON Data provided must include property "iso_a2" for each country Feature in order for this component to function properly. See here for a useful tool for generating GeoJSON country vector maps.
Usage
Install
First, ensure you have maplibre-gl installed:
npm install maplibre-gl
npm install @kong-ui-public/analytics-geo-map
Color mode (light/dark theme)
The map fills countries and water with design token colors, because maplibre-gl paint
properties require literal color values rather than var(--kui-*), the component reads those tokens
off the document.
To keep the map in step with the host's theme, provide a ComputedRef<'light' | 'dark'> under the
app:konnectColorMode injection key. The component resolves its colors whenever the value
changes.
// In the host application (e.g. within your root component's setup)
import { computed, provide } from 'vue'
// `isDarkMode` is however your app tracks its current theme
const colorMode = computed<'light' | 'dark'>(() => (isDarkMode.value ? 'dark' : 'light'))
provide('app:konnectColorMode', colorMode)
Props
countryMetrics
- type:
Object(Record<string, number>) - required:
true - description: An object mapping country codes to metric values. These metrics determine the color of each country on the map.
metricUnit
- type:
String(MetricUnits) - required:
true - description: Unit of measurement for the metrics displayed in the tooltips.
metric
- type:
String(ExploreAggregations) - required:
true - description: Metric aggregations for the data displayed on the map.
withLegend
- type:
Boolean - required:
false - default:
true - description: Whether to display a legend on the map.
showTooltipValue
- type:
Boolean - required:
false - default:
true - description: Display value in the tooltip.
fitToCountry
- type:
String(CountryISOA2) - required:
false - default:
null - description: Country code to zoom in on.
bounds
- type:
Object(LngLatBoundsLike) - required:
false - default:
null - description: Longitudinal/Latitudinal bounds to initially fit the map to.
Example
<template>
<AnalyticsGeoMap
:countryMetrics="countryMetrics"
:geoJsonData="geoJsonData"
:fitToCountry="'US'"
metricUnit="%"
/>
<!-- bounds to europe -->
<AnalyticsGeoMap
:countryMetrics="countryMetrics"
:geoJsonData="geoJsonData"
:bounds="[
[-10, 35],
[65, 72]
]"
metricUnit="%"
/>
</template>
<script setup>
import { ref } from 'vue'
import AnalyticsGeoMap from '@kong-ui-public/analytics-geo-map'
import geoJsonData from './path-to-geojson-data.json'
const countryMetrics = ref({
US: 75,
CA: 50,
MX: 25,
// Other countries
})
</script>
Related Packages
A kong UI Monaco Editor wrapper for Vue 3 with syntax highlighting powered by Sh...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.10.7 | ^3.5.35 | Apache-2.0 | |
| 1.10.6 | ^3.5.35 | Apache-2.0 | |
| 1.10.5 | ^3.5.35 | Apache-2.0 | |
| 1.10.4 | ^3.5.35 | Apache-2.0 | |
| 1.10.3 | ^3.5.35 | Apache-2.0 | |
| 1.10.2 | ^3.5.35 | Apache-2.0 | |
| 1.10.1 | ^3.5.35 | Apache-2.0 | |
| 1.10.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.57 | ^3.5.35 | Apache-2.0 | |
| 1.9.56 | ^3.5.35 | Apache-2.0 | |
| 1.9.55 | ^3.5.35 | Apache-2.0 | |
| 1.9.54 | ^3.5.35 | Apache-2.0 | |
| 1.9.53 | ^3.5.35 | Apache-2.0 | |
| 1.9.52 | ^3.5.35 | Apache-2.0 | |
| 1.9.51 | ^3.5.35 | Apache-2.0 | |
| 1.9.50 | ^3.5.35 | Apache-2.0 | |
| 1.9.49 | ^3.5.35 | Apache-2.0 | |
| 1.9.48 | ^3.5.35 | Apache-2.0 | |
| 1.9.47 | ^3.5.35 | Apache-2.0 | |
| 1.9.46 | ^3.5.35 | Apache-2.0 | |
| 1.9.45 | ^3.5.35 | Apache-2.0 | |
| 1.9.44 | ^3.5.35 | Apache-2.0 | |
| 1.9.43 | ^3.5.35 | Apache-2.0 | |
| 1.9.42 | ^3.5.35 | Apache-2.0 | |
| 1.9.41 | ^3.5.35 | Apache-2.0 | |
| 1.9.40 | ^3.5.35 | Apache-2.0 | |
| 1.9.39 | ^3.5.35 | Apache-2.0 | |
| 1.9.38 | ^3.5.35 | Apache-2.0 | |
| 1.9.37 | ^3.5.35 | Apache-2.0 | |
| 1.9.36 | ^3.5.35 | Apache-2.0 |
Showing the latest 30 of 366. See every release on npm
Pre-releases (852)
| Version | Released | Vue | License |
|---|---|---|---|
| 1.10.7-pr.3963.2c49bbcf6.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.6-pr.3942.610c75649.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.6-pr.3942.72fef96ff.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.6-pr.3942.5ca52595d.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.6-pr.3942.81480683f.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.5-pr.3958.a67cf049b.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.5-pr.3958.1339dfc7e.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.5-pr.3942.b9fcfd083.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.5-pr.3942.f63457f4d.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.4-pr.3948.a10ca59e2.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.4-pr.3942.51b727767.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.3-pr.3939.2da2cd39f.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.3-pr.3939.78e65d8b1.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.3-pr.3939.6b901f23b.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3935.a0363af83.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3935.d7df689d8.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3938.e96aaa11a.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3935.5b581b7d6.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3929.5235ddd81.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.2-pr.3935.f14e87a36.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.1-pr.3932.3d322d4f9.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.1-pr.3932.0a868f20c.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.1-pr.3927.1f93fac1c.0 | ^3.5.35 | Apache-2.0 | |
| 1.10.1-pr.3927.57f42237f.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.58-pr.3923.fc1bf4295.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.58-pr.3923.2760ff225.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.58-pr.3930.1d0c90197.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.58-pr.3930.1dcd46774.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.57-pr.3927.05ccc9860.0 | ^3.5.35 | Apache-2.0 | |
| 1.9.57-pr.3928.01d6dd5e2.0 | ^3.5.35 | Apache-2.0 |
Showing the latest 30 of 852. See every release on npm