Skip to content

Commit 07e338a

Browse files
chore: release v0.1.2
1 parent 0e21726 commit 07e338a

File tree

11 files changed

+315
-30
lines changed

11 files changed

+315
-30
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
# Changelog
22

33

4+
## v0.1.1...main
5+
6+
[compare changes](https://github.com/stacksjs/ts-maps/compare/v0.1.1...main)
7+
8+
### 🏡 Chore
9+
10+
- Wip ([f7c0e2d](https://github.com/stacksjs/ts-maps/commit/f7c0e2d))
11+
- Wip ([dbf0e4b](https://github.com/stacksjs/ts-maps/commit/dbf0e4b))
12+
- Wip ([7a9c774](https://github.com/stacksjs/ts-maps/commit/7a9c774))
13+
- Wip ([f581b23](https://github.com/stacksjs/ts-maps/commit/f581b23))
14+
- Wip ([8a5d334](https://github.com/stacksjs/ts-maps/commit/8a5d334))
15+
- Wip ([af8ae39](https://github.com/stacksjs/ts-maps/commit/af8ae39))
16+
- Wip ([64a8ad0](https://github.com/stacksjs/ts-maps/commit/64a8ad0))
17+
- Wip ([05e1d71](https://github.com/stacksjs/ts-maps/commit/05e1d71))
18+
- Wip ([89ccd8b](https://github.com/stacksjs/ts-maps/commit/89ccd8b))
19+
- Wip ([cbab5b5](https://github.com/stacksjs/ts-maps/commit/cbab5b5))
20+
- Wip ([0e21726](https://github.com/stacksjs/ts-maps/commit/0e21726))
21+
22+
### ❤️ Contributors
23+
24+
- Glennmichael123 ([@glennmichael123](https://github.com/glennmichael123))
25+
426
## v0.1.0...main
527

628
[compare changes](https://github.com/stacksjs/ts-maps/compare/v0.1.0...main)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ts-maps",
33
"type": "module",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"private": true,
66
"description": "A modern vector map library.",
77
"author": "Chris Breuer <[email protected]>",

packages/nuxt/package.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ts-maps-nuxt",
33
"type": "module",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"description": "Nuxt components for ts-maps - Interactive Vector Maps",
66
"author": "Chris Breuer <[email protected]>",
77

@@ -24,15 +24,11 @@
2424
"dist"
2525
],
2626
"scripts": {
27-
"prepack": "nuxt-module-build build",
27+
"build": "nuxt-module-build build",
2828
"dev": "npm run dev:prepare && nuxi dev playground",
2929
"dev:build": "nuxi build playground",
3030
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
31-
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
32-
"lint": "eslint .",
33-
"test": "vitest run",
34-
"test:watch": "vitest watch",
35-
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
31+
"lint": "eslint ."
3632
},
3733
"dependencies": {
3834
"@nuxt/kit": "^4.0.3"
@@ -42,13 +38,7 @@
4238
"@nuxt/eslint-config": "^1.8.0",
4339
"@nuxt/module-builder": "^1.0.2",
4440
"@nuxt/schema": "^4.0.3",
45-
"@nuxt/test-utils": "^3.19.2",
46-
"@types/node": "latest",
47-
"changelogen": "^0.6.2",
48-
"eslint": "^9.33.0",
4941
"nuxt": "^4.0.3",
50-
"typescript": "~5.9.2",
51-
"vitest": "^3.2.4",
52-
"vue-tsc": "^3.0.5"
42+
"typescript": "~5.9.2"
5343
}
5444
}

packages/nuxt/playground/app.vue

Lines changed: 276 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,278 @@
1+
<script setup lang="ts">
2+
import type { MapOptions } from 'ts-maps'
3+
import { computed, reactive, ref } from 'vue'
4+
5+
type MapName = 'world' | 'world-merc' | 'us-merc' | 'us-mill' | 'us-lcc' | 'us-aea' | 'spain' | 'italy' | 'canada'
6+
7+
interface EventData {
8+
type: string
9+
code?: string
10+
marker?: any
11+
time: string
12+
}
13+
14+
const isDarkTheme = ref(false)
15+
const lastEvent = ref<EventData | null>(null)
16+
const currentMap = ref<MapName>('world')
17+
18+
const mapOptions = [
19+
{ value: 'world', label: 'World Map', projection: 'miller' },
20+
{ value: 'world-merc', label: 'World (Mercator)', projection: 'mercator' },
21+
{ value: 'us-merc', label: 'USA (Mercator)', projection: 'mercator' },
22+
{ value: 'us-mill', label: 'USA (Miller)', projection: 'miller' },
23+
{ value: 'us-lcc', label: 'USA (Lambert)', projection: 'lambert' },
24+
{ value: 'us-aea', label: 'USA (Albers)', projection: 'albers' },
25+
{ value: 'spain', label: 'Spain', projection: 'mercator' },
26+
{ value: 'italy', label: 'Italy', projection: 'mercator' },
27+
{ value: 'canada', label: 'Canada', projection: 'mercator' },
28+
]
29+
30+
const options = reactive<Omit<MapOptions, 'selector'>>({
31+
backgroundColor: '#ffffff',
32+
zoomOnScroll: true,
33+
zoomButtons: true,
34+
regionsSelectable: true,
35+
markersSelectable: true,
36+
37+
regionStyle: {
38+
initial: {
39+
fill: '#e4e4e4',
40+
stroke: '#ffffff',
41+
strokeWidth: 0.5,
42+
},
43+
hover: {
44+
fill: '#2ca25f',
45+
},
46+
selected: {
47+
fill: '#1a9850',
48+
},
49+
},
50+
visualizeData: {
51+
scale: ['#C8EEFF', '#0071A4'],
52+
values: {
53+
'US-CA': 100, // California
54+
'US-TX': 85, // Texas
55+
'US-FL': 80, // Florida
56+
'US-NY': 75, // New York
57+
'US-IL': 70, // Illinois
58+
'US-PA': 65, // Pennsylvania
59+
},
60+
},
61+
markers: [
62+
{
63+
name: 'Sample Marker',
64+
coords: [40.7128, -74.0060],
65+
style: {
66+
fill: '#ff0000',
67+
stroke: '#ffffff',
68+
r: 5,
69+
},
70+
},
71+
],
72+
})
73+
74+
const currentProjection = computed(() => {
75+
const selectedMap = mapOptions.find(map => map.value === currentMap.value)
76+
77+
if (!selectedMap)
78+
return 'unknown'
79+
80+
return selectedMap.projection
81+
})
82+
83+
function toggleTheme() {
84+
isDarkTheme.value = !isDarkTheme.value
85+
options.backgroundColor = isDarkTheme.value ? '#2c3e50' : '#ffffff'
86+
if (options.regionStyle) {
87+
options.regionStyle = {
88+
...options.regionStyle,
89+
initial: {
90+
...options.regionStyle.initial,
91+
fill: isDarkTheme.value ? '#34495e' : '#e4e4e4',
92+
stroke: isDarkTheme.value ? '#1a1a1a' : '#ffffff',
93+
},
94+
}
95+
}
96+
}
97+
98+
function addRandomMarker() {
99+
const lat = Math.random() * 180 - 90
100+
const lng = Math.random() * 360 - 180
101+
const marker = {
102+
name: `Marker ${options.markers?.length ?? 0 + 1}`,
103+
coords: [lat, lng] as [number, number],
104+
style: {
105+
fill: `#${Math.floor(Math.random() * 16777215).toString(16)}`,
106+
stroke: '#ffffff',
107+
r: 5,
108+
},
109+
}
110+
options.markers = [...(options.markers || []), marker]
111+
}
112+
113+
function toggleZoom() {
114+
options.zoomOnScroll = !options.zoomOnScroll
115+
}
116+
117+
function handleRegionClick(_event: MouseEvent, code: string) {
118+
lastEvent.value = {
119+
type: 'Region Click',
120+
code,
121+
time: new Date().toLocaleTimeString(),
122+
}
123+
}
124+
125+
function handleMarkerClick(_event: MouseEvent, index: string) {
126+
lastEvent.value = {
127+
type: 'Marker Click',
128+
marker: options.markers?.[Number.parseInt(index)],
129+
time: new Date().toLocaleTimeString(),
130+
}
131+
}
132+
133+
function handleLoaded() {
134+
options.projection = 'albers'
135+
lastEvent.value = {
136+
type: 'Map Loaded',
137+
time: new Date().toLocaleTimeString(),
138+
}
139+
}
140+
</script>
141+
1142
<template>
2-
<TestComponent />
143+
<div class="container">
144+
<h1>ts-maps Vue Example</h1>
145+
146+
<div class="controls">
147+
<div class="control-group">
148+
<label for="map-select">Select Map:</label>
149+
<select id="map-select" v-model="currentMap">
150+
<option v-for="map in mapOptions" :key="map.value" :value="map.value">
151+
{{ map.label }} ({{ map.projection }})
152+
</option>
153+
</select>
154+
</div>
155+
156+
<div class="control-info">
157+
Current Projection: <strong>{{ currentProjection }}</strong>
158+
</div>
159+
160+
<button @click="toggleTheme">
161+
Toggle Theme
162+
</button>
163+
<button @click="addRandomMarker">
164+
Add Random Marker
165+
</button>
166+
<button @click="toggleZoom">
167+
{{ options.zoomOnScroll ? 'Disable' : 'Enable' }} Zoom
168+
</button>
169+
</div>
170+
171+
<div class="map-container">
172+
<UnitedStates
173+
:key="currentMap"
174+
:options="options"
175+
height="500px"
176+
@region-click="handleRegionClick"
177+
@marker-click="handleMarkerClick"
178+
@loaded="handleLoaded"
179+
>
180+
<template #loading>
181+
<div class="custom-loading">
182+
Loading your beautiful map...
183+
</div>
184+
</template>
185+
</UnitedStates>
186+
</div>
187+
188+
<div v-if="lastEvent" class="info-panel">
189+
<h3>Last Event</h3>
190+
<pre>{{ lastEvent }}</pre>
191+
</div>
192+
</div>
3193
</template>
194+
195+
<style scoped>
196+
.container {
197+
max-width: 1200px;
198+
margin: 0 auto;
199+
padding: 20px;
200+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
201+
}
202+
203+
.controls {
204+
margin: 20px 0;
205+
padding: 20px;
206+
background: #f5f5f5;
207+
border-radius: 8px;
208+
display: flex;
209+
flex-wrap: wrap;
210+
gap: 15px;
211+
align-items: center;
212+
}
213+
214+
.control-group {
215+
display: flex;
216+
align-items: center;
217+
gap: 10px;
218+
}
219+
220+
.control-group label {
221+
font-weight: 500;
222+
}
223+
224+
.control-group select {
225+
padding: 8px;
226+
border-radius: 4px;
227+
border: 1px solid #ddd;
228+
background: white;
229+
min-width: 200px;
230+
}
231+
232+
.controls button {
233+
padding: 8px 16px;
234+
border: none;
235+
border-radius: 4px;
236+
background: #2ca25f;
237+
color: white;
238+
cursor: pointer;
239+
}
240+
241+
.controls button:hover {
242+
background: #1a9850;
243+
}
244+
245+
.map-container {
246+
border: 1px solid #ddd;
247+
border-radius: 8px;
248+
overflow: hidden;
249+
}
250+
251+
.custom-loading {
252+
display: flex;
253+
align-items: center;
254+
justify-content: center;
255+
height: 100%;
256+
background: rgba(255, 255, 255, 0.9);
257+
font-size: 1.2em;
258+
color: #666;
259+
}
260+
261+
.info-panel {
262+
margin-top: 20px;
263+
padding: 15px;
264+
background: #f9f9f9;
265+
border-radius: 8px;
266+
}
267+
268+
.control-info {
269+
padding: 8px 16px;
270+
background: #fff;
271+
border-radius: 4px;
272+
border: 1px solid #ddd;
273+
}
274+
275+
.control-info strong {
276+
color: #2ca25f;
277+
}
278+
</style>

packages/nuxt/src/runtime/components/VectorMaps/Canada.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ const mapKey = computed(() => {
4949
return `canada-map-${optionsHash.length}-${Date.now()}`
5050
})
5151
52+
// Create options without projection to avoid overriding map-name
53+
const mapOptions = computed(() => {
54+
const { projection, ...rest } = props.options
55+
return rest
56+
})
57+
5258
// Watch for options changes to update the map if needed
5359
watch(() => props.options, () => {
5460
// The mapKey computed will automatically update, forcing a re-render
@@ -58,10 +64,9 @@ watch(() => props.options, () => {
5864
<template>
5965
<VectorMap
6066
:key="mapKey"
61-
:options="options"
67+
:options="mapOptions"
6268
map-name="canada"
6369
:height="height"
64-
v-bind="$attrs"
6570
@region-click="(event: MouseEvent, code: string) => emit('regionClick', event, code)"
6671
@marker-click="(event: MouseEvent, index: string) => emit('markerClick', event, index)"
6772
@loaded="() => emit('loaded')"

0 commit comments

Comments
 (0)