forked from Esri/arcgis-maps-sdk-dotnet-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdentifyGraphicsVB.xaml.vb
92 lines (73 loc) · 3.62 KB
/
IdentifyGraphicsVB.xaml.vb
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
' Copyright 2016 Esri.
'
' Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
' You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
'
' Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
' language governing permissions and limitations under the License.
Imports Esri.ArcGISRuntime.Data
Imports Esri.ArcGISRuntime.Geometry
Imports Esri.ArcGISRuntime.Mapping
Imports Esri.ArcGISRuntime.Symbology
Imports Esri.ArcGISRuntime.UI
Imports Esri.ArcGISRuntime.UI.Controls
Imports Windows.UI
Imports Windows.UI.Popups
Namespace IdentifyGraphics
Partial Public NotInheritable Class IdentifyGraphicsVB
' Graphics overlay to host graphics
Private _polygonOverlay As GraphicsOverlay
Public Sub New()
Me.InitializeComponent()
' Create the UI, setup the control references and execute initialization
Initialize()
End Sub
Private Sub Initialize()
' Create a map with 'Imagery with Labels' basemap and an initial location
Dim myMap As New Map(Basemap.CreateTopographic())
' Create graphics overlay with graphics
CreateOverlay()
' Hook into tapped event
AddHandler MyMapView.GeoViewTapped, AddressOf OnMapViewTapped
' Assign the map to the MapView
MyMapView.Map = myMap
End Sub
Private Sub CreateOverlay()
' Create polygon builder and add polygon corners into it
Dim builder As New PolygonBuilder(SpatialReferences.WebMercator)
builder.AddPoint(New MapPoint(-2000000.0, 2000000.0))
builder.AddPoint(New MapPoint(2000000.0, 2000000.0))
builder.AddPoint(New MapPoint(2000000.0, -2000000.0))
builder.AddPoint(New MapPoint(-2000000.0, -2000000.0))
' Get geometry from the builder
Dim polygonGeometry As Polygon = builder.ToGeometry()
' Create symbol for the polygon
Dim polygonSymbol As New SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Colors.Yellow, Nothing)
' Create new graphic
Dim polygonGraphic As New Graphic(polygonGeometry, polygonSymbol)
' Create overlay to where graphics are shown
_polygonOverlay = New GraphicsOverlay()
_polygonOverlay.Graphics.Add(polygonGraphic)
' Add created overlay to the MapView
MyMapView.GraphicsOverlays.Add(_polygonOverlay)
End Sub
Private Async Sub OnMapViewTapped(sender As Object, e As GeoViewInputEventArgs)
' Use larger tolerance for touch
Dim tolerance = 10.0
' Only return one graphic
Dim maximumResults = 1
' Don't return only popups
Dim onlyReturnPopups As Boolean = False
' Use the following method to identify graphics in a specific graphics overlay
Dim identifyResults As IdentifyGraphicsOverlayResult =
Await MyMapView.IdentifyGraphicsOverlayAsync(_polygonOverlay, e.Position, tolerance, onlyReturnPopups, maximumResults)
' Check if we got results
If identifyResults.Graphics.Count > 0 Then
' Display to the user the identify worked.
Dim message = New MessageDialog("Tapped on graphic", "").ShowAsync()
End If
End Sub
End Class
End Namespace