Repository navigation
Expand file tree
/
Copy pathMapViewFeaturesWindow.xaml
More file actions
632 lines (603 loc) · 31.6 KB
/
Copy pathMapViewFeaturesWindow.xaml
File metadata and controls
632 lines (603 loc) · 31.6 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<wd:Window
x:Class="WPFDevelopers.Samples.ExampleViews.MapViewFeaturesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
Title="MapView 功能演示"
Width="1181"
Height="760"
MinWidth="900"
MinHeight="620"
Icon="pack://application:,,,/WPFDevelopers.Samples;component/WPFDevelopers.ico"
WindowStartupLocation="CenterOwner"
mc:Ignorable="d">
<wd:Window.Resources>
<DataTemplate x:Key="CustomClusterTemplate" DataType="{x:Type wd:PushpinCluster}">
<Grid
Width="52"
Height="52"
ToolTip="{Binding Representative.Title}">
<Ellipse Fill="#332563EB" />
<Ellipse
Width="42"
Height="42"
Fill="#FF2563EB"
Stroke="White"
StrokeThickness="2" />
<Grid
Width="34"
Height="34"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Viewbox
Width="9"
Height="11"
VerticalAlignment="Center">
<Path Data="{StaticResource WD.FlagGeometry}" Fill="White" />
</Viewbox>
<TextBlock
Grid.Column="1"
Margin="2,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="12"
FontWeight="SemiBold"
Foreground="White"
Text="{Binding CountText}"
TextAlignment="Center" />
</Grid>
</Grid>
</DataTemplate>
<DataTemplate x:Key="StationPushpinTemplate">
<Grid Width="42" Height="48">
<Ellipse
Width="34"
Height="34"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="#FF16A34A"
Stroke="White"
StrokeThickness="2" />
<Viewbox
Width="16"
Height="16"
Margin="0,8,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top">
<Path Data="{StaticResource WD.FlagGeometry}" Fill="White" />
</Viewbox>
<Path
Margin="0,29,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Data="M 0,0 L 12,0 L 6,12 Z"
Fill="#FF16A34A" />
</Grid>
</DataTemplate>
<DataTemplate x:Key="CustomMapPinTemplate">
<Grid Width="30" Height="40">
<Viewbox
IsHitTestVisible="False"
RenderTransformOrigin="0.5,1"
Stretch="Fill">
<Canvas Width="30" Height="40">
<Ellipse
Canvas.Left="9"
Canvas.Top="34"
Width="12"
Height="3"
Fill="{DynamicResource WD.MapPinShadowBrush}"
IsHitTestVisible="False" />
<Path
Canvas.Left="5"
Canvas.Top="3"
Width="30"
Height="40"
Data="{DynamicResource WD.MapPinGeometry}"
Fill="{DynamicResource WD.MapPinFillBrush}"
Stroke="{DynamicResource WD.MapPinStrokeBrush}"
StrokeThickness="1.1" />
<Ellipse
Canvas.Left="10.25"
Canvas.Top="11"
Width="9.5"
Height="9.5"
Fill="{DynamicResource WD.MapPinInnerFillBrush}"
Stroke="{DynamicResource WD.MapPinInnerStrokeBrush}"
StrokeThickness="0.9" />
<Ellipse
Canvas.Left="10.9"
Canvas.Top="8"
Width="5.5"
Height="2.0"
Fill="{DynamicResource WD.MapPinHighlightBrush}">
<Ellipse.RenderTransform>
<RotateTransform Angle="-18" />
</Ellipse.RenderTransform>
</Ellipse>
</Canvas>
</Viewbox>
</Grid>
</DataTemplate>
<DataTemplate x:Key="RunningPushpinTemplate">
<Grid
Width="36"
Height="36"
RenderTransformOrigin="0.5,1">
<Grid.RenderTransform>
<RotateTransform Angle="{Binding Tag}" />
</Grid.RenderTransform>
<wd:SvgViewer
Width="36"
Height="36"
VerticalAlignment="Bottom"
Source="pack://application:,,,/WPFDevelopers.Samples;component/Resources/Svg/Running.svg" />
</Grid>
</DataTemplate>
<Style BasedOn="{StaticResource WD.MapPinStyle}" TargetType="{x:Type wd:MapPin}">
<Setter Property="IsHitTestVisible" Value="False" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Width" Value="30" />
<Setter Property="Height" Value="40" />
<Setter Property="RenderTransformOrigin" Value="0.5,1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type wd:MapPin}">
<Viewbox
IsHitTestVisible="False"
RenderTransformOrigin="0.5,1"
Stretch="Fill">
<Grid Width="30" Height="40">
<Path
Width="28"
Height="36"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Data="M14,0 C7.4,0 2,5.4 2,12.1 C2,19.1 14,36 14,36 C14,36 26,19.1 26,12.1 C26,5.4 20.6,0 14,0 Z"
Fill="#FF2563EB"
Stroke="White"
StrokeThickness="2" />
<Ellipse
Width="12"
Height="12"
Margin="0,6,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="White" />
</Grid>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.5" ScaleY="1.5" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" ScaleY="1" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</wd:Window.Resources>
<controls:CodeViewer Padding="0" Header="MapView 功能演示">
<wd:Drawer
x:Name="FeatureDrawer"
HeaderWidth="292"
IsOpen="True"
Position="Right">
<wd:Drawer.Header>
<Border
Width="292"
Background="White"
BorderBrush="#FFDCE3EC"
BorderThickness="1,0,0,0">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Margin="10,0">
<TextBlock
FontSize="20"
FontWeight="SemiBold"
Foreground="#FF111827"
Text="功能设置" />
<TextBlock
Margin="0,4,0,18"
Foreground="#FF64748B"
Text="实时切换 MapView 常用能力" />
<TextBlock
Margin="0,0,0,8"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="地图源" />
<wd:Segmented
x:Name="MapStyleSegmented"
ItemClick="MapStyleSegmented_ItemClick"
SelectedIndex="1">
<wd:SegmentedItem Content="卫星" />
<wd:SegmentedItem Content="标准" />
<wd:SegmentedItem Content="道路" />
</wd:Segmented>
<Separator Margin="0,18" />
<CheckBox
x:Name="ClusteringCheckBox"
Margin="0,0,0,10"
Click="ClusteringCheckBox_Click"
Content="启用点位聚合"
IsChecked="True" />
<CheckBox
x:Name="ClusterTemplateCheckBox"
Margin="0,0,0,10"
Click="ClusterTemplateCheckBox_Click"
Content="使用自定义聚合模板"
IsChecked="True" />
<CheckBox
x:Name="ScaleBarCheckBox"
Margin="0,0,0,10"
Click="ScaleBarCheckBox_Click"
Content="显示比例尺"
IsChecked="True" />
<CheckBox
x:Name="ZoomControlCheckBox"
Margin="0,0,0,10"
Click="ZoomControlCheckBox_Click"
Content="显示缩放控制"
IsChecked="True" />
<CheckBox
x:Name="DiagnosticsCheckBox"
Margin="0,0,0,10"
Click="DiagnosticsCheckBox_Click"
Content="显示诊断信息" />
<CheckBox
x:Name="ClickZoomCheckBox"
Margin="0,0,0,10"
Click="ClickZoomCheckBox_Click"
Content="点击点位时自动缩放"
IsChecked="True" />
<CheckBox
x:Name="AlertLayerCheckBox"
Click="AlertLayerCheckBox_Click"
Content="显示独立业务图层"
IsChecked="True" />
<Separator Margin="0,18" />
<TextBlock Foreground="#FF334155" Text="聚合半径" />
<Grid Margin="0,6,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="42" />
</Grid.ColumnDefinitions>
<Slider
x:Name="ClusterRadiusSlider"
Maximum="80"
Minimum="16"
TickFrequency="4"
ValueChanged="ClusterRadiusSlider_ValueChanged"
Value="42" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#FF475569"
Text="{Binding Value, ElementName=ClusterRadiusSlider, StringFormat={}{0:0}}" />
</Grid>
<TextBlock Foreground="#FF334155" Text="最小聚合数量" />
<Grid Margin="0,6,0,18">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="42" />
</Grid.ColumnDefinitions>
<Slider
x:Name="ClusterMinimumSlider"
IsSnapToTickEnabled="True"
Maximum="10"
Minimum="2"
TickFrequency="1"
ValueChanged="ClusterMinimumSlider_ValueChanged"
Value="3" />
<TextBlock
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#FF475569"
Text="{Binding Value, ElementName=ClusterMinimumSlider, StringFormat={}{0:0}}" />
</Grid>
<TextBlock
Margin="0,0,0,8"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="示例包含" />
<TextBlock
Foreground="#FF64748B"
LineHeight="22"
Text="默认 Pushpin与自定义 Pushpin
ClusterTemplate 与 99+ 数量显示
折线、多边形与动态点集合
比例尺、诊断信息与点击缩放" />
<Border
Margin="0,16,0,0"
Padding="10"
Background="#F8FAFC"
BorderBrush="#FFE2E8F0"
BorderThickness="1"
CornerRadius="8">
<StackPanel>
<TextBlock
Margin="0,0,0,8"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="坐标转换演示" />
<TextBlock
Margin="0,0,0,6"
Foreground="#FF475569"
Text="来源坐标系" />
<wd:Segmented x:Name="CoordinateSourceSegmented" SelectedIndex="0">
<wd:SegmentedItem Content="WGS84" />
<wd:SegmentedItem Content="GCJ02" />
<wd:SegmentedItem Content="BD09" />
</wd:Segmented>
<TextBlock
Margin="0,10,0,6"
Foreground="#FF475569"
Text="目标坐标系" />
<wd:Segmented x:Name="CoordinateTargetSegmented" SelectedIndex="1">
<wd:SegmentedItem Content="WGS84" />
<wd:SegmentedItem Content="GCJ02" />
<wd:SegmentedItem Content="BD09" />
</wd:Segmented>
<Grid Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,6,0">
<TextBlock
Margin="0,0,0,4"
Foreground="#FF475569"
Text="经度" />
<TextBox x:Name="CoordinateLongitudeTextBox" Text="116.397428" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="6,0,0,0">
<TextBlock
Margin="0,0,0,4"
Foreground="#FF475569"
Text="纬度" />
<TextBox x:Name="CoordinateLatitudeTextBox" Text="39.909230" />
</StackPanel>
<Button
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="0,10,0,0"
Click="ConvertCoordinateButton_Click"
Content="转换"
Style="{StaticResource WD.PrimaryButton}" />
</Grid>
<TextBlock
Margin="0,12,0,0"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="结果" />
<TextBlock
x:Name="CoordinateConvertResultTextBlock"
Margin="0,6,0,0"
Foreground="#FF0F172A"
LineHeight="20"
Text="WGS84 -> GCJ02" />
</StackPanel>
</Border>
<Button
Margin="0,20,0,0"
Click="MovePushpinButton_Click"
Content="移动首个动态点位" />
<Separator Margin="0,16" />
<TextBlock
Margin="0,0,0,8"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="ShapeZIndex 演示" />
<Button
Margin="0,0,0,8"
Click="BringCircleToFrontButton_Click"
Content="Circle 置顶(动态修改)" />
<Button
Margin="0,0,0,8"
Click="ResetShapeZIndexButton_Click"
Content="恢复默认层级" />
<Separator Margin="0,16" />
<TextBlock
Margin="0,0,0,8"
FontWeight="SemiBold"
Foreground="#FF334155"
Text="跑步演示" />
<Button
Margin="0,0,0,8"
Click="StartRunningButton_Click"
Content="开始跑步" />
<Button
Margin="0,0,0,8"
Click="PauseRunningButton_Click"
Content="暂停跑步" />
<Button
Margin="0,0,0,8"
Click="ResumeRunningButton_Click"
Content="继续跑步" />
<Button
Margin="0,0,0,8"
Click="FocusRunnerButton_Click"
Content="定位跑步点" />
<Button
Margin="0,8,0,0"
Click="ResetViewButton_Click"
Content="重置地图视图"
Style="{StaticResource WD.PrimaryButton}" />
</StackPanel>
</ScrollViewer>
</Border>
</wd:Drawer.Header>
<wd:Drawer.Content>
<Grid Background="#FFF3F6FA">
<Grid>
<wd:MapView
x:Name="DemoMap"
CenterLatitude="39.905"
CenterLongitude="116.205"
ClusterMinimumCount="3"
ClusterRadius="42"
ClusterTemplate="{StaticResource CustomClusterTemplate}"
EnableClustering="True"
MapClicked="DemoMap_MapClicked"
MapFeatureClicked="DemoMap_MapFeatureClicked"
PushpinClickZoomLevel="15"
ShowScaleBar="True"
ShowZoomControls="True"
ZoomControlPosition="BottomRight"
ZoomLevel="11">
<wd:MapView.Polylines>
<wd:MapPolyline Stroke="#FF16A34A" StrokeThickness="4">
<wd:MapPolyline.Points>
<wd:MapLocation Latitude="39.882" Longitude="116.145" />
<wd:MapLocation Latitude="39.902" Longitude="116.188" />
<wd:MapLocation Latitude="39.918" Longitude="116.236" />
<wd:MapLocation Latitude="39.942" Longitude="116.274" />
</wd:MapPolyline.Points>
</wd:MapPolyline>
<wd:MapPolyline
IsClosed="True"
Stroke="#FFF97316"
StrokeThickness="3">
<wd:MapPolyline.Points>
<wd:MapLocation Latitude="39.918694" Longitude="116.148180" />
<wd:MapLocation Latitude="39.920537" Longitude="116.156420" />
<wd:MapLocation Latitude="39.915797" Longitude="116.162256" />
<wd:MapLocation Latitude="39.908292" Longitude="116.167578" />
<wd:MapLocation Latitude="39.900391" Longitude="116.175474" />
<wd:MapLocation Latitude="39.898284" Longitude="116.166548" />
<wd:MapLocation Latitude="39.904342" Longitude="116.156248" />
<wd:MapLocation Latitude="39.911320" Longitude="116.150240" />
</wd:MapPolyline.Points>
</wd:MapPolyline>
</wd:MapView.Polylines>
<wd:MapView.Polygons>
<wd:MapPolygon
Fill="#332563EB"
Stroke="#FF2563EB"
StrokeThickness="2">
<wd:MapPolygon.Points>
<wd:MapLocation Latitude="39.886" Longitude="116.156" />
<wd:MapLocation Latitude="39.895" Longitude="116.245" />
<wd:MapLocation Latitude="39.938" Longitude="116.263" />
<wd:MapLocation Latitude="39.943" Longitude="116.170" />
</wd:MapPolygon.Points>
</wd:MapPolygon>
</wd:MapView.Polygons>
<wd:MapView.Circles>
<wd:MapCircle
x:Name="DemoCircle"
CenterLatitude="39.9042"
CenterLongitude="116.4074"
Fill="#33EF4444"
RadiusMeters="300000"
ShapeZIndex="10"
Stroke="#FFEF4444"
StrokeThickness="2" />
</wd:MapView.Circles>
<wd:MapView.Rectangles>
<wd:MapRectangle
x:Name="DemoRectangle"
Fill="#334F46E5"
MaxLatitude="40.2200"
MaxLongitude="117.5000"
MinLatitude="39.4500"
MinLongitude="115.7000"
ShapeZIndex="20"
Stroke="#FF4F46E5"
StrokeThickness="2" />
</wd:MapView.Rectangles>
<wd:Pushpin
Title="自定义中心点"
AnchorPoint="0.5,1"
Latitude="39.905"
Longitude="116.205"
Template="{StaticResource StationPushpinTemplate}" />
<wd:Pushpin
Title="自定义 Marker"
AnchorPoint="0.5,1"
Latitude="39.924"
Longitude="116.241"
Template="{StaticResource CustomMapPinTemplate}" />
</wd:MapView>
<Border
Margin="16"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#EFFFFFFF"
BorderBrush="#FFDCE3EC"
BorderThickness="1"
CornerRadius="6">
<StackPanel>
<TextBlock
FontSize="16"
FontWeight="SemiBold"
Foreground="#FF111827"
Text="MapView 综合功能" />
<TextBlock
Margin="0,3,0,0"
FontSize="12"
Foreground="#FF64748B"
Text="拖动、滚轮缩放并点击点位查看效果" />
<TextBlock
Margin="0,8,0,0"
FontSize="11"
Foreground="#FF334155"
Text="要素点击" />
<TextBlock
x:Name="FeatureClickInfoTextBlock"
Margin="0,8,0,0"
FontSize="11"
Foreground="#FF0F172A"
Text="点击点、线、面查看命中结果" />
<TextBlock
Margin="0,8,0,0"
FontSize="11"
Foreground="#FF334155"
Text="地图点击" />
<TextBlock
x:Name="MapClickInfoTextBlock"
Margin="0,4,0,0"
FontSize="11"
Foreground="#FF0F172A"
Text="点击地图获取坐标" />
</StackPanel>
</Border>
<Button
Width="34"
Height="34"
Margin="16"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Click="ToggleFeatureDrawerButton_Click"
Content="☰"
Style="{StaticResource WD.PrimaryButton}" />
</Grid>
</Grid>
</wd:Drawer.Content>
</wd:Drawer>
<controls:CodeViewer.SourceCodes>
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/Map/MapViewFeaturesWindow.xaml" CodeType="Xaml" />
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/Map/MapViewFeaturesWindow.xaml.cs" CodeType="CSharp" />
</controls:CodeViewer.SourceCodes>
</controls:CodeViewer>
</wd:Window>