Private Sub RequestData(attributes As IDictionary(Of String, Object)) If attributes IsNot Nothing AndAlso Not String.IsNullOrEmpty(ObjectIDField) AndAlso attributes.ContainsKey(ObjectIDField) AndAlso TypeOf attributes(ObjectIDField) Is Integer Then Dim objectId As Integer = CInt(attributes(ObjectIDField)) If objectId = _currentId OrElse _cachedItems.Contains(objectId) Then 'Item has already been requested Return End If Dim qt As New QueryTask() With {.Url = QueryUrl} Dim q As New Query() q.ReturnGeometry = True If QueryOutFields IsNot Nothing Then For Each outfield As String In QueryOutFields If Not attributes.ContainsKey(outfield) Then q.OutFields.Add(outfield) End If Next Else q.OutFields.Add("*") End If If q.OutFields.Count > 0 Then _cachedItems.Add(objectId) q.Where = String.Format("{0}={1}", ObjectIDField, objectId) AddHandler qt.ExecuteCompleted, AddressOf qt_ExecuteCompleted AddHandler qt.Failed, AddressOf qt_Failed qt.ExecuteAsync(q, New Object() {attributes, objectId}) _currentId = objectId _dataRequestInProcess = True ChangeVisualState(True) End If End If End Sub Private Sub qt_ExecuteCompleted(sender As Object, e As QueryEventArgs) Dim state() As Object = CType(e.UserState, Object()) Dim attr As IDictionary(Of String, Object) = TryCast(state(0), IDictionary(Of String, Object)) Dim oid As Integer = CInt(state(1)) If e.FeatureSet.Features.Count > 0 Then 'Copy the attributes over to the attribute collection for the feature we requested for For Each item As KeyValuePair(Of String, Object) In e.FeatureSet.Features(0).Attributes attr(item.Key) = item.Value Next attr.Add(New KeyValuePair(Of String, Object)("_geometry", e.FeatureSet.Features(0).Geometry)) If _currentId = oid Then 'False if a new element got opened before request returned _dataRequestInProcess = False ChangeVisualState(True) End If End If End Sub
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.