-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoMapCompare.vue
More file actions
219 lines (196 loc) · 5.04 KB
/
DemoMapCompare.vue
File metadata and controls
219 lines (196 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<script lang="ts">
import { defineComponent, ref, PropType } from 'vue'
import { MapCompare } from '../../src/index'
import type { StyleSpecification } from 'maplibre-gl'
import type { SwiperOptions } from '../../src/components/MapCompare.vue'
export default defineComponent({
name: 'DemoMapCompare',
components: {
MapCompare
},
props: {
swiperOptions: {
type: Object as PropType<SwiperOptions>,
required: true,
},
},
setup() {
// Simple inline styles for testing without external tile servers
const openStreetMapStyle: StyleSpecification = {
version: 8,
name: 'Open Street Map',
sources: {
osm: {
type: 'raster',
tiles: [
'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png',
'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png',
],
tileSize: 256,
attribution: '© OpenStreetMap contributors',
},
},
layers: [
{
id: 'osm-tiles',
type: 'raster',
source: 'osm',
minzoom: 0,
maxzoom: 19,
},
]
}
const naipStyle: StyleSpecification = {
version: 8,
name: 'NAIP Imagery',
sources: {
'naip-imagery': {
type: 'raster',
tiles: [
// eslint-disable-next-line vue/max-len
'https://gis.apfo.usda.gov/arcgis/rest/services/NAIP/USDA_CONUS_PRIME/ImageServer/tile/{z}/{y}/{x}?blankTile=false',
],
tileSize: 256,
},
},
layers: [
{
id: 'naip-imagery-tiles',
type: 'raster',
source: 'naip-imagery',
},
]
}
const nyImagery: StyleSpecification = {
version: 8,
name: 'NY Imagery',
sources: {
'ny-imagery': {
type: 'raster',
tiles: [
"https://orthos.its.ny.gov/arcgis/services/wms/Latest/MapServer/WmsServer?" +
"service=WMS&" +
"request=GetMap&" +
"version=1.3.0&" +
"layers=0,1,2,3&" +
"styles=&" +
"format=image/png&" +
"transparent=true&" +
"width=256&height=256&" +
"crs=EPSG:3857&" +
"bbox={bbox-epsg-3857}"
],
tileSize: 256,
},
},
layers: [
{
id: 'ny-imagery-tiles',
type: 'raster',
source: 'ny-imagery',
},
]
}
const availableStyles = [
openStreetMapStyle,
naipStyle,
nyImagery
]
const selectedStyleIndexA = ref(0)
const selectedStyleIndexB = ref(1)
// Layer control - these would be populated dynamically in a real app
const selectedLayersA = ref<string[]>([])
const selectedLayersB = ref<string[]>([])
return {
availableStyles,
selectedStyleIndexA,
selectedStyleIndexB,
selectedLayersA,
selectedLayersB,
}
}
})
</script>
<template>
<div class="demo-map-compare">
<div class="controls">
<div class="control-group">
<h3>Map A Style</h3>
<select v-model="selectedStyleIndexA">
<option :value="0">OpenStreetMap Style</option>
<option :value="1">NAIP Imagery</option>
<option :value="2">NY Imagery</option>
</select>
</div>
<div class="control-group">
<h3>Map B Style</h3>
<select v-model="selectedStyleIndexB">
<option :value="0">OpenStreetMap Style</option>
<option :value="1">NAIP Imagery</option>
<option :value="2">NY Imagery</option>
</select>
</div>
</div>
<div class="info">
<p><strong>Instructions:</strong> Click and drag the slider to compare the two maps. Use your mouse or touch
to pan, zoom, and rotate both maps simultaneously.</p>
</div>
<div class="map-container">
<MapCompare :mapStyleA="availableStyles[selectedStyleIndexA]" :mapStyleB="availableStyles[selectedStyleIndexB]"
:mapLayersA="selectedLayersA" :mapLayersB="selectedLayersB"
:camera="{ center: [-74.1847, 43.1339], zoom: 9, bearing: 0, pitch: 0 }" :swiperOptions="swiperOptions" />
</div>
</div>
</template>
<style scoped>
.demo-map-compare {
display: flex;
flex-direction: column;
height: 100%;
}
.controls {
display: flex;
gap: 20px;
padding: 15px 20px;
background: #ecf0f1;
border-bottom: 1px solid #bdc3c7;
}
.control-group {
flex: 1;
}
.control-group h3 {
margin-bottom: 8px;
color: #2c3e50;
font-size: 14px;
font-weight: 600;
}
.control-group select {
width: 100%;
padding: 8px 12px;
border: 1px solid #bdc3c7;
border-radius: 4px;
background: white;
font-size: 14px;
cursor: pointer;
}
.control-group select:focus {
outline: none;
border-color: #3498db;
}
.info {
padding: 12px 20px;
background: #fff3cd;
border-bottom: 1px solid #ffc107;
color: #856404;
}
.info p {
font-size: 13px;
line-height: 1.5;
}
.map-container {
flex: 1;
position: relative;
min-height: 500px;
}
</style>