Select to view content in your preferred language

VB - Query not displaying graphics

512
0
08-21-2013 07:00 AM
GaryWine
Deactivated User
I am attempting to execute a simple query of a rest service containing a point feature class. When I build out the query I am receiving no errors. When I run the application in a browser I receive error 400: invalid or missing parameters.


XAML Code:
<UserControl x:Class="crime_map.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="1200">

    <Grid x:Name="LayoutRoot" Background="White">
       
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Size="6" Color="Red" Style="Circle" />
        </Grid.Resources>
       
        <esri:Map Background="White" WrapAround="True" x:Name="crimeMap">
            <esri:ArcGISTiledMapServiceLayer Url="http://maps.berkeleywv.org/arcgis/rest/services/Constant/berkeley_relief_base_07172013/MapServer"/>
            <esri:GraphicsLayer ID="MyGraphicsLayer" />
        </esri:Map>
       
        <TextBox x:Name="zipText" Text="25401" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" Width="60"/>
        <Button x:Name="zipsearchBtn" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="75,10,0,0" Height="25" Content="Search" />

    </Grid>
</UserControl>

VB:

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Tasks

Partial Public Class MainPage
    Inherits UserControl

    Public Sub New()
        InitializeComponent()

        Dim zipQuery As New QueryTask("http://maps.berkeleywv.org/arcgis/rest/services/law_enforcement/crime_2013/MapServer/0")
        AddHandler zipQuery.ExecuteCompleted, AddressOf QueryTask_ExecuteCompleted
        AddHandler zipQuery.Failed, AddressOf QueryTask_Failed

        Dim zipcodeQuery As New ESRI.ArcGIS.Client.Tasks.Query()

        zipcodeQuery.ReturnGeometry = True
        zipcodeQuery.OutFields.Add("zipcode")
        zipcodeQuery.Where = zipText.Text
        zipQuery.ExecuteAsync(zipcodeQuery)
    End Sub

    Private Sub QueryTask_ExecuteCompleted(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
        Dim featureSet As FeatureSet = args.FeatureSet
        Dim graphicsLayer As GraphicsLayer = TryCast(crimeMap.Layers("MyGraphicsLayer"), GraphicsLayer)

        If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
            MessageBox.Show("No features found")
            Return
        End If

        For Each graphic As Graphic In featureSet.Features
            graphic.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol"), ESRI.ArcGIS.Client.Symbols.Symbol)
            graphicsLayer.Graphics.Add(graphic)
        Next
    End Sub

    Private Sub QueryTask_Failed(ByVal sender As Object, ByVal args As TaskFailedEventArgs)
        MessageBox.Show("Query failed: " & args.Error.ToString())
    End Sub

End Class


My apologies if this is not posted properly.

Thanks in advance for the help.
0 Kudos
0 Replies