Skip to content

Commit 6131964

Browse files
committed
feat(google-maps): support transitions with data-state
1 parent dcf9b50 commit 6131964

File tree

10 files changed

+579
-91
lines changed

10 files changed

+579
-91
lines changed

docs/content/scripts/google-maps/1.guides/2.map-styling.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,31 @@ Styles automatically apply to both the static map placeholder and the interactiv
1414
<script setup lang="ts">
1515
const mapOptions = {
1616
styles: [
17-
{ elementType: 'labels', stylers: [{ visibility: 'off' }, { color: '#f49f53' }] },
18-
{ featureType: 'landscape', stylers: [{ color: '#f9ddc5' }, { lightness: -7 }] },
19-
{ featureType: 'road', stylers: [{ color: '#813033' }, { lightness: 43 }] },
20-
{ featureType: 'water', stylers: [{ color: '#1994bf' }, { saturation: -69 }, { gamma: 0.99 }, { lightness: 43 }] },
21-
{ featureType: 'poi.park', stylers: [{ color: '#645c20' }, { lightness: 39 }] },
17+
{
18+
elementType: 'labels',
19+
stylers: [{ visibility: 'off' }, { color: '#f49f53' }],
20+
},
21+
{
22+
featureType: 'landscape',
23+
stylers: [{ color: '#f9ddc5' }, { lightness: -7 }],
24+
},
25+
{
26+
featureType: 'road',
27+
stylers: [{ color: '#813033' }, { lightness: 43 }],
28+
},
29+
{
30+
featureType: 'water',
31+
stylers: [
32+
{ color: '#1994bf' },
33+
{ saturation: -69 },
34+
{ gamma: 0.99 },
35+
{ lightness: 43 },
36+
],
37+
},
38+
{
39+
featureType: 'poi.park',
40+
stylers: [{ color: '#645c20' }, { lightness: 39 }],
41+
},
2242
],
2343
}
2444
</script>

docs/content/scripts/google-maps/1.guides/4.markers-and-info-windows.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ title: "Example: Markers & Info Windows"
99
```vue [Source]
1010
<script setup lang="ts">
1111
const showPopup = ref(false)
12+
13+
const greenPin = {
14+
background: '#34a853',
15+
borderColor: '#1e8e3e',
16+
glyphColor: '#fff',
17+
}
1218
</script>
1319
1420
<template>
@@ -23,7 +29,7 @@ const showPopup = ref(false)
2329
2430
<!-- Colored pin -->
2531
<ScriptGoogleMapsAdvancedMarkerElement :position="{ lat: -33.8523, lng: 151.2108 }">
26-
<ScriptGoogleMapsPinElement :options="{ background: '#34a853', borderColor: '#1e8e3e', glyphColor: '#fff' }" />
32+
<ScriptGoogleMapsPinElement :options="greenPin" />
2733
</ScriptGoogleMapsAdvancedMarkerElement>
2834
2935
<!-- Custom HTML marker with popup -->
@@ -36,7 +42,11 @@ const showPopup = ref(false)
3642
$1.2M
3743
</div>
3844
</template>
39-
<ScriptGoogleMapsOverlayView v-model:open="showPopup" anchor="bottom-center" :offset="{ x: 0, y: -40 }">
45+
<ScriptGoogleMapsOverlayView
46+
v-model:open="showPopup"
47+
anchor="bottom-center"
48+
:offset="{ x: 0, y: -40 }"
49+
>
4050
<div class="bg-white p-3 px-4 rounded-lg shadow-lg max-w-[200px]">
4151
<strong>Town Hall</strong>
4252
<p>3 bed, 2 bath apartment</p>
@@ -72,17 +82,28 @@ const showPopup = ref(false)
7282
Use `ScriptGoogleMapsPinElement` to customize the pin appearance while keeping the standard shape.
7383

7484
```vue
85+
<script setup lang="ts">
86+
const redPin = {
87+
background: '#FF0000',
88+
borderColor: '#CC0000',
89+
glyphColor: '#FFFFFF',
90+
scale: 1.2,
91+
}
92+
93+
const bluePin = {
94+
background: '#4285F4',
95+
borderColor: '#1a73e8',
96+
glyphColor: '#FFFFFF',
97+
}
98+
</script>
99+
75100
<template>
76101
<ScriptGoogleMaps :center="{ lat: -33.8688, lng: 151.2093 }" :zoom="13">
77102
<ScriptGoogleMapsAdvancedMarkerElement :position="{ lat: -33.8568, lng: 151.2153 }">
78-
<ScriptGoogleMapsPinElement
79-
:options="{ background: '#FF0000', borderColor: '#CC0000', glyphColor: '#FFFFFF', scale: 1.2 }"
80-
/>
103+
<ScriptGoogleMapsPinElement :options="redPin" />
81104
</ScriptGoogleMapsAdvancedMarkerElement>
82105
<ScriptGoogleMapsAdvancedMarkerElement :position="{ lat: -33.8688, lng: 151.2093 }">
83-
<ScriptGoogleMapsPinElement
84-
:options="{ background: '#4285F4', borderColor: '#1a73e8', glyphColor: '#FFFFFF' }"
85-
/>
106+
<ScriptGoogleMapsPinElement :options="bluePin" />
86107
</ScriptGoogleMapsAdvancedMarkerElement>
87108
</ScriptGoogleMaps>
88109
</template>

docs/content/scripts/google-maps/1.guides/5.shapes-and-overlays.md

Lines changed: 118 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,56 @@ const routePath = [
1414
{ lat: -33.8650, lng: 151.2090 },
1515
{ lat: -33.8688, lng: 151.2093 },
1616
]
17+
18+
const circleOptions = {
19+
center: { lat: -33.8688, lng: 151.2093 },
20+
radius: 800,
21+
fillColor: '#4285F4',
22+
fillOpacity: 0.12,
23+
strokeColor: '#4285F4',
24+
strokeWeight: 2,
25+
}
26+
27+
const polygonOptions = {
28+
paths: [
29+
{ lat: -33.852, lng: 151.213 },
30+
{ lat: -33.850, lng: 151.220 },
31+
{ lat: -33.856, lng: 151.222 },
32+
{ lat: -33.858, lng: 151.215 },
33+
],
34+
fillColor: '#34a853',
35+
fillOpacity: 0.15,
36+
strokeColor: '#34a853',
37+
strokeWeight: 2,
38+
}
39+
40+
const polylineOptions = {
41+
path: routePath,
42+
strokeColor: '#ea4335',
43+
strokeOpacity: 1.0,
44+
strokeWeight: 3,
45+
}
46+
47+
const rectangleOptions = {
48+
bounds: {
49+
north: -33.870,
50+
south: -33.878,
51+
east: 151.218,
52+
west: 151.200,
53+
},
54+
fillColor: '#fbbc04',
55+
fillOpacity: 0.15,
56+
strokeColor: '#fbbc04',
57+
strokeWeight: 2,
58+
}
1759
</script>
1860
1961
<template>
2062
<ScriptGoogleMaps :center="{ lat: -33.863, lng: 151.210 }" :zoom="14">
21-
<ScriptGoogleMapsCircle
22-
:options="{ center: { lat: -33.8688, lng: 151.2093 }, radius: 800, fillColor: '#4285F4', fillOpacity: 0.12, strokeColor: '#4285F4', strokeWeight: 2 }"
23-
/>
24-
<ScriptGoogleMapsPolygon
25-
:options="{ paths: [{ lat: -33.852, lng: 151.213 }, { lat: -33.850, lng: 151.220 }, { lat: -33.856, lng: 151.222 }, { lat: -33.858, lng: 151.215 }], fillColor: '#34a853', fillOpacity: 0.15, strokeColor: '#34a853', strokeWeight: 2 }"
26-
/>
27-
<ScriptGoogleMapsPolyline
28-
:options="{ path: routePath, strokeColor: '#ea4335', strokeOpacity: 1.0, strokeWeight: 3 }"
29-
/>
30-
<ScriptGoogleMapsRectangle
31-
:options="{ bounds: { north: -33.870, south: -33.878, east: 151.218, west: 151.200 }, fillColor: '#fbbc04', fillOpacity: 0.15, strokeColor: '#fbbc04', strokeWeight: 2 }"
32-
/>
63+
<ScriptGoogleMapsCircle :options="circleOptions" />
64+
<ScriptGoogleMapsPolygon :options="polygonOptions" />
65+
<ScriptGoogleMapsPolyline :options="polylineOptions" />
66+
<ScriptGoogleMapsRectangle :options="rectangleOptions" />
3367
</ScriptGoogleMaps>
3468
</template>
3569
```
@@ -41,20 +75,24 @@ All shape components are placed inside `<ScriptGoogleMaps>`{lang="html"} and acc
4175
## Circle: Delivery Radius
4276

4377
```vue
78+
<script setup lang="ts">
79+
const center = { lat: -33.8688, lng: 151.2093 }
80+
81+
const circleOptions = {
82+
center,
83+
radius: 2000,
84+
fillColor: '#4285F4',
85+
fillOpacity: 0.15,
86+
strokeColor: '#4285F4',
87+
strokeOpacity: 0.8,
88+
strokeWeight: 2,
89+
}
90+
</script>
91+
4492
<template>
45-
<ScriptGoogleMaps :center="{ lat: -33.8688, lng: 151.2093 }" :zoom="13">
46-
<ScriptGoogleMapsAdvancedMarkerElement :position="{ lat: -33.8688, lng: 151.2093 }" />
47-
<ScriptGoogleMapsCircle
48-
:options="{
49-
center: { lat: -33.8688, lng: 151.2093 },
50-
radius: 2000,
51-
fillColor: '#4285F4',
52-
fillOpacity: 0.15,
53-
strokeColor: '#4285F4',
54-
strokeOpacity: 0.8,
55-
strokeWeight: 2,
56-
}"
57-
/>
93+
<ScriptGoogleMaps :center="center" :zoom="13">
94+
<ScriptGoogleMapsAdvancedMarkerElement :position="center" />
95+
<ScriptGoogleMapsCircle :options="circleOptions" />
5896
</ScriptGoogleMaps>
5997
</template>
6098
```
@@ -70,19 +108,19 @@ const zoneBoundary = [
70108
{ lat: -33.878, lng: 151.205 },
71109
{ lat: -33.870, lng: 151.195 },
72110
]
111+
112+
const polygonOptions = {
113+
paths: zoneBoundary,
114+
fillColor: '#34a853',
115+
fillOpacity: 0.2,
116+
strokeColor: '#34a853',
117+
strokeWeight: 2,
118+
}
73119
</script>
74120
75121
<template>
76122
<ScriptGoogleMaps :center="{ lat: -33.865, lng: 151.210 }" :zoom="14">
77-
<ScriptGoogleMapsPolygon
78-
:options="{
79-
paths: zoneBoundary,
80-
fillColor: '#34a853',
81-
fillOpacity: 0.2,
82-
strokeColor: '#34a853',
83-
strokeWeight: 2,
84-
}"
85-
/>
123+
<ScriptGoogleMapsPolygon :options="polygonOptions" />
86124
</ScriptGoogleMaps>
87125
</template>
88126
```
@@ -97,23 +135,26 @@ const routePath = [
97135
{ lat: -33.8650, lng: 151.2090 },
98136
{ lat: -33.8688, lng: 151.2093 },
99137
]
138+
139+
const polylineOptions = {
140+
path: routePath,
141+
strokeColor: '#ea4335',
142+
strokeOpacity: 1.0,
143+
strokeWeight: 3,
144+
}
145+
146+
const startPin = { background: '#34a853' }
147+
const endPin = { background: '#ea4335' }
100148
</script>
101149
102150
<template>
103151
<ScriptGoogleMaps :center="{ lat: -33.862, lng: 151.212 }" :zoom="15">
104-
<ScriptGoogleMapsPolyline
105-
:options="{
106-
path: routePath,
107-
strokeColor: '#ea4335',
108-
strokeOpacity: 1.0,
109-
strokeWeight: 3,
110-
}"
111-
/>
152+
<ScriptGoogleMapsPolyline :options="polylineOptions" />
112153
<ScriptGoogleMapsAdvancedMarkerElement :position="routePath[0]">
113-
<ScriptGoogleMapsPinElement :options="{ background: '#34a853' }" />
154+
<ScriptGoogleMapsPinElement :options="startPin" />
114155
</ScriptGoogleMapsAdvancedMarkerElement>
115156
<ScriptGoogleMapsAdvancedMarkerElement :position="routePath[routePath.length - 1]">
116-
<ScriptGoogleMapsPinElement :options="{ background: '#ea4335' }" />
157+
<ScriptGoogleMapsPinElement :options="endPin" />
117158
</ScriptGoogleMapsAdvancedMarkerElement>
118159
</ScriptGoogleMaps>
119160
</template>
@@ -122,22 +163,24 @@ const routePath = [
122163
## Rectangle: Bounding Box
123164

124165
```vue
166+
<script setup lang="ts">
167+
const rectangleOptions = {
168+
bounds: {
169+
north: -33.855,
170+
south: -33.875,
171+
east: 151.225,
172+
west: 151.195,
173+
},
174+
fillColor: '#fbbc04',
175+
fillOpacity: 0.15,
176+
strokeColor: '#fbbc04',
177+
strokeWeight: 2,
178+
}
179+
</script>
180+
125181
<template>
126182
<ScriptGoogleMaps :center="{ lat: -33.865, lng: 151.210 }" :zoom="14">
127-
<ScriptGoogleMapsRectangle
128-
:options="{
129-
bounds: {
130-
north: -33.855,
131-
south: -33.875,
132-
east: 151.225,
133-
west: 151.195,
134-
},
135-
fillColor: '#fbbc04',
136-
fillOpacity: 0.15,
137-
strokeColor: '#fbbc04',
138-
strokeWeight: 2,
139-
}"
140-
/>
183+
<ScriptGoogleMapsRectangle :options="rectangleOptions" />
141184
</ScriptGoogleMaps>
142185
</template>
143186
```
@@ -167,26 +210,38 @@ const geoJson = {
167210
},
168211
],
169212
}
213+
214+
const geoJsonStyle = {
215+
fillColor: '#4285F4',
216+
fillOpacity: 0.3,
217+
strokeColor: '#4285F4',
218+
strokeWeight: 2,
219+
}
170220
</script>
171221
172222
<template>
173223
<ScriptGoogleMaps :center="{ lat: -33.885, lng: 151.225 }" :zoom="13">
174-
<ScriptGoogleMapsGeoJson
175-
:src="geoJson"
176-
:style="{ fillColor: '#4285F4', fillOpacity: 0.3, strokeColor: '#4285F4', strokeWeight: 2 }"
177-
/>
224+
<ScriptGoogleMapsGeoJson :src="geoJson" :style="geoJsonStyle" />
178225
</ScriptGoogleMaps>
179226
</template>
180227
```
181228

182229
### Remote URL
183230

184231
```vue
232+
<script setup lang="ts">
233+
const geoJsonStyle = {
234+
fillColor: '#34a853',
235+
fillOpacity: 0.2,
236+
strokeWeight: 1,
237+
}
238+
</script>
239+
185240
<template>
186241
<ScriptGoogleMaps :center="{ lat: -33.885, lng: 151.225 }" :zoom="10">
187242
<ScriptGoogleMapsGeoJson
188243
src="https://example.com/boundaries.geojson"
189-
:style="{ fillColor: '#34a853', fillOpacity: 0.2, strokeWeight: 1 }"
244+
:style="geoJsonStyle"
190245
/>
191246
</ScriptGoogleMaps>
192247
</template>

0 commit comments

Comments
 (0)