Skip to content

Map Core docs โ€‹

Core map functionality and components built on MapLibre GL

๐Ÿš€ Introduction โ€‹

Map Core provides the fundamental components and utilities for building interactive maps: the Map container, navigation controls, settings, coordinates display, fullscreen, geolocate, and more.

๐Ÿ“ฆ Installation โ€‹

Vue โ€‹

bash
npm install @hungpvq/vue-map-core

React โ€‹

bash
npm install @hungpvq/react-map-core

๐ŸŽฏ Features โ€‹

  • โœ… Map container - Main MapLibre GL wrapper component
  • โœ… Navigation controls - Zoom, Home, Fullscreen, Geolocate
  • โœ… Info controls - Mouse coordinates, Settings, map INFO panel, worker monitor, right-click context menu
  • โœ… Compare & CRS extras - Optional extras for map compare and CRS
  • โœ… Composable hooks - useMap, useShow and more
  • โœ… TypeScript support - Full TypeScript types
  • โœ… Vue 3 / React - Framework wrappers over @hungpvq/map-core

๐Ÿš€ Usage โ€‹

Vue โ€‹

vue
<template>
  <Map :mapId="mapId" @map-loaded="onMapLoaded">
    <ZoomControl position="top-right" />
    <HomeControl position="top-right" />
    <FullScreenControl position="top-right" />
    <MouseCoordinatesControl position="bottom-right" />
    <WorkerControl position="top-left" />
    <MapContextMenuControl />
  </Map>

  <!-- Optional extras -->
  <!-- <CrsControl position="bottom-right" /> -->
  <!-- <EventManagementControl position="top-right" /> -->
  <!-- <ActionControl position="top-right" /> -->
  <!-- <CompareSettingControl position="top-right" /> -->
  <!-- <MapCompare /> -->
</template>

<script setup lang="ts">
import { ref } from 'vue';
import {
  Map,
  ZoomControl,
  HomeControl,
  FullScreenControl,
  MouseCoordinatesControl,
  MapContextMenuControl,
  WorkerControl,
} from '@hungpvq/vue-map-core';
import '@hungpvq/vue-map-core/style.css';

const mapId = ref('map-core');

function onMapLoaded(map: any) {
  console.info('Map loaded:', map);
}
</script>

React โ€‹

tsx
import {
  Map,
  ZoomControl,
  HomeControl,
  FullScreenControl,
  MouseCoordinatesControl,
  MapContextMenuControl,
  WorkerControl,
} from '@hungpvq/react-map-core';
import '@hungpvq/react-map-core/style.css';

function App() {
  return (
    <Map mapId="map-core" onMapLoaded={(map) => console.info('Map loaded:', map)}>
      <ZoomControl position="top-right" />
      <HomeControl position="top-right" />
      <FullScreenControl position="top-right" />
      <MouseCoordinatesControl position="bottom-right" />
      <WorkerControl position="top-left" />
      <MapContextMenuControl />
    </Map>
  );
}

Open / move / run controls from code: UniversalRegistry controls.

Demo (Vue / React): Vue #/registry-control ยท React #/registry-control.