6 Replies Latest reply: May 1, 2012 9:41 AM by yassinofski

    Query

    yassinofski
      Hi,
      I want a code that show points with a query.
      for example, i want to show cities(points) where population >200 000 .
      Please can anyone help me ?
      Thanks
        • Re: Query
          dbroux-esristaff
          The easiest way is to use a feature layer with a where clause (sample).
          You can also manage the query by yourself, see others query samples.
          • Re: Query
            yassinofski
            Thank you dominique,
            how can i use a feature with a where clause ??
            and for query samples....i dont find a query about a feature layer (point)...i found just for polygons !!
            can you give me an example of a query ?
            • Re: Query
              dbroux-esristaff
              how can i use a feature with a where clause ??

              Did you look at the sample I pointed out?
              In this sample, the feature layer is defined in XAML with a where clause:
                  <esri:FeatureLayer ID="AttributeFilterFeatureLayer"
                                  Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0" 
                                  Where="POP1990 > 1000000" Renderer="{StaticResource MySimplePointRenderer}" >
                  </esri:FeatureLayer>
              



              and for query samples....i dont find a query about a feature layer (point)...i found just for polygons !!

              There is not that much difference between polygon and point, you have just to replace the fill symbol by a marker symbol.

              For example in this sample, the impacted lines are:

                             // Highlight selected feature
                              selectedFeature.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; 
                              graphicsLayer.Graphics.Add(selectedFeature);
              
              • Re: Query
                yassinofski
                Thank you,
                its a good idea to use a feature layer with a where clause , but i want that the user who tape the condition (clause where).
                for example i want that the user have a textbox and he enter the condition ...any idea ?
                • Re: Query
                  JNery-esristaff
                  Sure, you can subscribe to TextBox.KeyUp event (Key.Enter) or maybe on a Button.Click event, you can set Where clause by using the Text value.

                  For example;
                  var l = MyMap.Layers["MyFeatureLayer"] as FeatureLayer;
                  l.Where = string.Format("FieldName = '{0}'", MyTextBox.Text);
                  l.Update(); //to re-query the service applying the where clause.
                  
                  • Re: Query
                    yassinofski
                    Thank you too much,
                    i will try it