Select to view content in your preferred language

Address locator issue in search result envelope zooming

628
3
11-07-2012 11:44 PM
shariqueabdul
Emerging Contributor
Hi All

I m getting null exception error in this following code

Private Sub QueryTaskZoomSearch_ExecuteCompleted(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
        Dim featureSet1 As FeatureSet = args.FeatureSet

         
        Dim graphicsLayer As GraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayer"), GraphicsLayer)
        graphicsLayer.ClearGraphics()

        If featureSet1 IsNot Nothing AndAlso featureSet1.Features.Count > 0 Then
           
           
            Dim selectedFeature As Graphic = New Graphic
            selectedFeature = featureSet1.Features(1)
           

            Select Case featureSet1.GeometryType
                Case GeometryType.Point : selectedFeature.Symbol = DefaultMarkerSymbol
                Case GeometryType.Polygon : selectedFeature.Symbol = DefaultFillSymbol
                Case GeometryType.Polyline : selectedFeature.Symbol = DefaultLineSymbol
                Case GeometryType.Envelope : selectedFeature.Symbol = DefaultMarkerSymbol   // here it shows nothing in envelope
            End Select
            'selectedFeature.Symbol = DefaultFillSymbol

            graphicsLayer.Graphics.Add(selectedFeature)

            ' Zoom to selected feature (define expand percentage)
            Dim selectedFeatureExtent As ESRI.ArcGIS.Client.Geometry.Envelope = selectedFeature.Geometry.Extent


getting error in underline text .... object refernce is not set to an instance of an object

plz help
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
May be your featureset has only one feature so you should use
selectedFeature = featureSet1.Features(0)
0 Kudos
shariqueabdul
Emerging Contributor
May be your featureset has only one feature so you should use 
selectedFeature = featureSet1.Features(0)


Thanx dbroux for prompt reply

i checked with selectedFeature = featureSet1.Features(0) but still same error


plz help
thank you
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Is the selected feature's geometry a point?  if so then the geometry has no extent.  It's just a point.  If it is a point, try using selectedFeature.Geometry.Extent.Expand(10).  You might need to adjust the expand ratio to your liking.
0 Kudos