Skip to content

Commit 9c42468

Browse files
author
danhnguyen
committed
Add comprehensive documentation for markers and basic usage in Vue3 MapLibre GL
- Introduced a new section on markers, covering basic, draggable, multiple markers, markers with popups, and dynamic markers. - Added examples demonstrating how to create and customize markers, including event handling and styling. - Created a guide on basic usage of Vue MapLibre GL components, including map creation, data sources, markers, popups, and using composables. - Expanded configuration documentation detailing map options, component settings, and environment configurations for development and production.
1 parent d6a8732 commit 9c42468

File tree

22 files changed

+5044
-238
lines changed

22 files changed

+5044
-238
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ dist-ssr
2525

2626
.eslintcache
2727
.vercel
28+
29+
# VitePress
30+
docs/.vitepress/dist
31+
docs/.vitepress/cache

README.md

Lines changed: 274 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# Vue MapLibre GL
1+
# Vue3 MapLibre GL
22

33
[![npm](https://img.shields.io/npm/v/vue3-maplibre-gl)](https://www.npmjs.com/package/vue3-maplibre-gl) [![Downloads](https://img.shields.io/npm/dt/vue3-maplibre-gl)](https://www.npmjs.com/package/vue3-maplibre-gl) [![Stars](https://img.shields.io/github/stars/danh121097/vue-mapbox-gl?style=flat-square)](https://github.com/danh121097/vue-mapbox-gl/stargazers) [![License](https://img.shields.io/npm/l/vue3-maplibre-gl)](https://github.com/danh121097/vue-mapbox-gl/blob/main/LICENSE)
44

5-
> Vue 3 components and composables for MapLibre GL JS - Build interactive maps with ease
5+
> **The most comprehensive Vue 3 library for MapLibre GL JS** - Build interactive maps with 10+ components and 15+ composables
66
7-
A comprehensive Vue 3 component library for MapLibre GL JS that provides an intuitive, reactive way to build interactive maps in your Vue applications.
7+
A powerful, feature-rich Vue 3 component library that provides an intuitive, reactive way to build interactive maps in your Vue applications using MapLibre GL JS.
88

99
## ✨ Features
1010

11-
- 🗺️ **Interactive Maps** - Create beautiful, interactive maps with MapLibre GL JS
12-
- 🧩 **Component-Based** - Use Vue components for markers, layers, controls, and more
13-
- 🎯 **TypeScript Support** - Full TypeScript support with comprehensive type definitions
14-
- 🚀 **Performance** - Optimized for performance with efficient rendering
15-
- 🔧 **Composables** - Powerful composables for map interactions and state management
16-
- 📱 **Responsive** - Mobile-friendly maps that work across all devices
11+
- 🗺️ **Interactive Maps** - High-performance vector maps with WebGL rendering
12+
- 🧩 **10+ Vue Components** - Mapbox, GeoJsonSource, FillLayer, CircleLayer, LineLayer, SymbolLayer, Marker, PopUp, Image, GeolocateControls
13+
- 🔧 **15+ Composables** - Complete map management, animations, events, and utilities
14+
- 🎯 **Full TypeScript Support** - Comprehensive type definitions and interfaces
15+
-**High Performance** - Optimized rendering with automatic resource cleanup
16+
- 📱 **Mobile-Friendly** - Touch controls and responsive design for all devices
17+
- 🌐 **Self-Contained** - Bundled CSS and automatic dependency management
18+
- 🔄 **Reactive Data Binding** - Seamless integration with Vue 3's reactivity system
1719

1820
## 📦 Installation
1921

@@ -39,32 +41,237 @@ pnpm add vue3-maplibre-gl
3941

4042
```vue
4143
<template>
42-
<MapLibreMap
43-
:map-style="mapStyle"
44-
:center="[0, 0]"
45-
:zoom="2"
46-
style="height: 400px"
47-
>
48-
<MapLibreMarker :lng-lat="[0, 0]">
44+
<Mapbox :options="mapOptions" style="height: 500px" @load="onMapLoad">
45+
<!-- GeoJSON Data Source -->
46+
<GeoJsonSource :data="geoJsonData">
47+
<FillLayer :style="fillStyle" />
48+
<CircleLayer :style="circleStyle" />
49+
</GeoJsonSource>
50+
51+
<!-- Interactive Marker -->
52+
<Marker :lnglat="[0, 0]" :draggable="true">
4953
<div class="marker">📍</div>
50-
</MapLibreMarker>
51-
</MapLibreMap>
54+
</Marker>
55+
56+
<!-- Popup -->
57+
<PopUp :lnglat="[0, 0]" :show="true">
58+
<div class="popup-content">
59+
<h3>Welcome to Vue3 MapLibre GL!</h3>
60+
<p>Interactive maps made easy with Vue 3</p>
61+
</div>
62+
</PopUp>
63+
64+
<!-- Geolocation Control -->
65+
<GeolocateControls position="top-right" />
66+
</Mapbox>
5267
</template>
5368
5469
<script setup>
55-
import { MapLibreMap, MapLibreMarker } from 'vue3-maplibre-gl';
70+
import { ref } from 'vue';
71+
import {
72+
Mapbox,
73+
GeoJsonSource,
74+
FillLayer,
75+
CircleLayer,
76+
Marker,
77+
PopUp,
78+
GeolocateControls,
79+
} from 'vue3-maplibre-gl';
5680
import 'vue3-maplibre-gl/dist/style.css';
5781
58-
const mapStyle = 'https://demotiles.maplibre.org/style.json';
82+
const mapOptions = ref({
83+
style: 'https://demotiles.maplibre.org/style.json',
84+
center: [0, 0],
85+
zoom: 2,
86+
});
87+
88+
const geoJsonData = ref({
89+
type: 'FeatureCollection',
90+
features: [
91+
{
92+
type: 'Feature',
93+
geometry: { type: 'Point', coordinates: [0, 0] },
94+
properties: { name: 'Sample Point' },
95+
},
96+
],
97+
});
98+
99+
const fillStyle = ref({
100+
'fill-color': '#088',
101+
'fill-opacity': 0.8,
102+
});
103+
104+
const circleStyle = ref({
105+
'circle-radius': 6,
106+
'circle-color': '#007cbf',
107+
});
108+
109+
function onMapLoad(map) {
110+
console.log('Map loaded:', map);
111+
}
112+
</script>
113+
114+
<style>
115+
.marker {
116+
font-size: 24px;
117+
cursor: pointer;
118+
}
119+
120+
.popup-content {
121+
padding: 10px;
122+
max-width: 200px;
123+
}
124+
</style>
125+
```
126+
127+
## 🧩 Components
128+
129+
Vue3 MapLibre GL provides 10+ reactive Vue components:
130+
131+
| Component | Description |
132+
| --------------------- | ------------------------------------------------------------- |
133+
| **Mapbox** | Main map container with comprehensive event handling |
134+
| **GeoJsonSource** | Reactive data source for GeoJSON data with clustering support |
135+
| **FillLayer** | Render filled polygons with customizable styling |
136+
| **CircleLayer** | Display point data as circles with dynamic sizing |
137+
| **LineLayer** | Render linear features like routes and boundaries |
138+
| **SymbolLayer** | Display icons and text labels |
139+
| **Marker** | HTML markers with drag support and custom content |
140+
| **PopUp** | Interactive popup windows with custom HTML |
141+
| **Image** | Manage and load images for map styles |
142+
| **GeolocateControls** | User location tracking with comprehensive events |
143+
144+
## 🔧 Composables
145+
146+
15+ powerful composables for advanced map functionality:
147+
148+
### Map Management
149+
150+
- `useCreateMapbox` - Enhanced map creation with error handling
151+
- `useMapbox` - Simplified map state management
152+
153+
### Layer Management
154+
155+
- `useCreateFillLayer` - Fill layer creation and management
156+
- `useCreateCircleLayer` - Circle layer for point visualization
157+
- `useCreateLineLayer` - Line layer for linear features
158+
- `useCreateSymbolLayer` - Symbol layer for icons and text
159+
160+
### Source Management
161+
162+
- `useCreateGeoJsonSource` - GeoJSON source with reactive data
163+
- `useGeoJsonSource` - Simplified source management
164+
165+
### Controls
166+
167+
- `useGeolocateControl` - User location tracking
168+
169+
### Events
170+
171+
- `useMapEventListener` - Map event handling
172+
- `useLayerEventListener` - Layer-specific events
173+
174+
### Utilities
175+
176+
- `useFlyTo` - Smooth map animations
177+
- `useEaseTo` - Easing animations
178+
- `useJumpTo` - Instant position changes
179+
- `useBounds` - Bounds management
180+
- `useZoom` - Zoom controls
181+
- `useLogger` - Consistent logging
182+
183+
## 🎯 TypeScript Support
184+
185+
Vue3 MapLibre GL includes comprehensive TypeScript support:
186+
187+
```typescript
188+
import { ref } from 'vue';
189+
import {
190+
Mapbox,
191+
GeoJsonSource,
192+
FillLayer,
193+
type MapboxProps,
194+
type FillLayerStyle,
195+
type GeoJSONSourceSpecification,
196+
} from 'vue3-maplibre-gl';
197+
198+
const mapOptions = ref<MapboxProps['options']>({
199+
style: 'https://demotiles.maplibre.org/style.json',
200+
center: [0, 0],
201+
zoom: 2,
202+
});
203+
204+
const fillStyle = ref<FillLayerStyle>({
205+
'fill-color': '#088',
206+
'fill-opacity': 0.8,
207+
});
208+
209+
const geoJsonData = ref<GeoJSONSourceSpecification['data']>({
210+
type: 'FeatureCollection',
211+
features: [],
212+
});
213+
```
214+
215+
## 🌟 Advanced Example with Composables
216+
217+
```vue
218+
<script setup>
219+
import { ref } from 'vue';
220+
import {
221+
useCreateMapbox,
222+
useFlyTo,
223+
useMapEventListener,
224+
useCreateGeoJsonSource,
225+
} from 'vue3-maplibre-gl';
226+
227+
const mapContainer = ref();
228+
const mapStyle = ref('https://demotiles.maplibre.org/style.json');
229+
230+
// Create map with enhanced error handling
231+
const { mapInstance, setCenter, setZoom } = useCreateMapbox(
232+
mapContainer,
233+
mapStyle,
234+
{
235+
onLoad: (map) => console.log('Map loaded:', map),
236+
onError: (error) => console.error('Map error:', error),
237+
debug: true,
238+
},
239+
);
240+
241+
// Add smooth animations
242+
const { flyTo } = useFlyTo({ map: mapInstance });
243+
244+
// Create reactive data source
245+
const { setData } = useCreateGeoJsonSource({
246+
map: mapInstance,
247+
id: 'my-source',
248+
data: { type: 'FeatureCollection', features: [] },
249+
});
250+
251+
// Listen to map events
252+
useMapEventListener({
253+
map: mapInstance,
254+
event: 'click',
255+
handler: (event) => {
256+
flyTo({
257+
center: event.lngLat,
258+
zoom: 12,
259+
duration: 2000,
260+
});
261+
},
262+
});
59263
</script>
60264
```
61265

62266
## 📚 Documentation
63267

64-
- **[Getting Started](https://danh121097.github.io/vue-mapbox-gl/guide/getting-started)** - Learn the basics
268+
- **[Getting Started](https://danh121097.github.io/vue-mapbox-gl/guide/getting-started)** - Learn the basics and see examples
65269
- **[Installation Guide](https://danh121097.github.io/vue-mapbox-gl/guide/installation)** - Detailed setup instructions
66-
- **[API Reference](https://danh121097.github.io/vue-mapbox-gl/api/components)** - Complete component documentation
67-
- **[Examples](https://danh121097.github.io/vue-mapbox-gl/examples/)** - Live examples and demos
270+
- **[Configuration](https://danh121097.github.io/vue-mapbox-gl/guide/configuration)** - Advanced configuration options
271+
- **[Components API](https://danh121097.github.io/vue-mapbox-gl/api/components)** - Complete component documentation
272+
- **[Composables API](https://danh121097.github.io/vue-mapbox-gl/api/composables)** - Composables reference
273+
- **[TypeScript Types](https://danh121097.github.io/vue-mapbox-gl/api/types)** - Type definitions
274+
- **[Live Examples](https://danh121097.github.io/vue-mapbox-gl/examples/)** - Interactive demos
68275

69276
## 🛠️ Development
70277

@@ -86,21 +293,61 @@ yarn build
86293
yarn docs:dev
87294
```
88295

296+
## 🌟 Why Choose Vue3 MapLibre GL?
297+
298+
- **🎯 Vue 3 Native** - Built specifically for Vue 3 with Composition API support
299+
- **🗺️ MapLibre GL JS** - Uses the open-source MapLibre GL JS for high-performance rendering
300+
- **🧩 Component-Based** - 10+ Vue components for maps, layers, sources, markers, and controls
301+
- **🔧 Powerful Composables** - 15+ composables for map management, animations, and utilities
302+
- **📚 Comprehensive Documentation** - Detailed guides, API references, and examples
303+
- **⚡ High Performance** - Optimized for performance with automatic resource cleanup
304+
- **🌐 Open Source** - MIT licensed with active community support
305+
- **📱 Mobile Ready** - Touch-friendly controls and responsive design
306+
89307
## 🤝 Contributing
90308

91309
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
92310

311+
### Development Setup
312+
313+
```bash
314+
# Clone the repository
315+
git clone https://github.com/danh121097/vue-mapbox-gl.git
316+
cd vue-mapbox-gl
317+
318+
# Install dependencies
319+
yarn install
320+
321+
# Start development server
322+
yarn dev
323+
324+
# Run tests
325+
yarn test
326+
327+
# Build the library
328+
yarn build
329+
330+
# Run documentation
331+
yarn docs:dev
332+
```
333+
93334
## 📄 License
94335

95336
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
96337

97338
## 🙏 Acknowledgments
98339

99-
- Built on top of [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/)
340+
- Built on top of [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) - The open-source mapping library
100341
- Inspired by the Vue.js ecosystem and community
342+
- Thanks to all contributors and users who make this project better
101343

102344
## 📞 Support
103345

104-
- 📖 [Documentation](https://danh121097.github.io/vue-mapbox-gl/)
105-
- 🐛 [Issues](https://github.com/danh121097/vue-mapbox-gl/issues)
106-
- 💬 [Discussions](https://github.com/danh121097/vue-mapbox-gl/discussions)
346+
- 📖 [Documentation](https://danh121097.github.io/vue-mapbox-gl/) - Comprehensive guides and API reference
347+
- 🐛 [Issues](https://github.com/danh121097/vue-mapbox-gl/issues) - Bug reports and feature requests
348+
- 💬 [Discussions](https://github.com/danh121097/vue-mapbox-gl/discussions) - Community discussions and questions
349+
-[GitHub](https://github.com/danh121097/vue-mapbox-gl) - Star the project if you find it useful!
350+
351+
---
352+
353+
**Made with ❤️ for the Vue.js community**

docs/.vitepress/config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineConfig({
44
title: 'Vue MapLibre GL',
55
description: 'Vue 3 components and composables for MapLibre GL JS',
66
base: '/',
7-
ignoreDeadLinks: true,
7+
ignoreDeadLinks: false,
88

99
// Ensure default theme is used
1010
appearance: 'dark',
@@ -27,9 +27,7 @@ export default defineConfig({
2727
},
2828

2929
// Ensure CSS is properly included
30-
head: [
31-
['meta', { name: 'theme-color', content: '#3c82f6' }]
32-
],
30+
head: [['meta', { name: 'theme-color', content: '#3c82f6' }]],
3331

3432
themeConfig: {
3533
nav: [

0 commit comments

Comments
 (0)