Select to view content in your preferred language

Set feature limit from Local Query

2734
3
09-10-2011 02:40 AM
Labels (1)
MarkCorbin
Occasional Contributor
I'm trying to use a query task against a local datasource (mpk) and it seems to only return the first 1000 features. Is there a way to change this?
0 Kudos
3 Replies
KerrieScholefield
Deactivated User
I'm trying to use a query task against a local datasource (mpk) and it seems to only return the first 1000 features. Is there a way to change this?


Hi Mark,

The default MaxRecords property is 1000 and can be changed by setting the MaxRecords property of the LocalMapService. The MaxRecords property cannot be set when the LocalMapService is running so it will need to be set before the service has started or by stopping and then starting the service.



  _localMapService = new LocalMapService()
      {
        Path = "..\\..\\..\\Data\\MPKS\\USCitiesStates.mpk",
        MaxRecords = 500000
      };

    _localMapService.Start();


Once the MaxRecords property has been set and the service started you can use it in the QueryTask by specifying the QueryTask.Url property as the LocalMapService.Url property.

       QueryTask queryTask = new QueryTask();    
        queryTask.Url = _localMapService.Url + "/0";
        queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
        queryTask.Failed += QueryTask_Failed;
        Query query = new ESRI.ArcGIS.Client.Tasks.Query();
        query.OutFields.AddRange(new string[] { "STATE_NAME", "POP2000" });
        query.Geometry = args.Geometry;
        query.ReturnGeometry = true;
        queryTask.ExecuteAsync(query);


Since beta 1 release we�??ve added the ability to set the MaxRecords property via an overload on the convenience method GetService and GetServiceAsync on LocalMapService.  This functionality will be available in beta 2 later on in the year.

Cheers

Kerrie
0 Kudos
MarkCorbin
Occasional Contributor
Hi Kerrie

Thanks. I now have this working.

I should have elaborated a bit more about what I was doing. I was actually defining a feature layer that implemented clustering and maptips to make sure that although I was returning a lot of features they were being displayed appropriately. The result of having to define my feature service programmatically to set the max records and then the feature layer programmatically means that I then have to either then write and set the flareclusterer in code and same with the maptips (or at least write them as data template in XAML and load them in code). This is quite a big overhead in terms of effort. If I had less than 1000 features then I could have declared everthing in a few lines XAML. Is there any chance the max records property could actually go on the feature layer instead. It would make things so much easier.

Thanks
Mark
0 Kudos
KerrieScholefield
Deactivated User

I should have elaborated a bit more about what I was doing. I was actually defining a feature layer that implemented clustering and maptips to make sure that although I was returning a lot of features they were being displayed appropriately. The result of having to define my feature service programmatically to set the max records and then the feature layer programmatically means that I then have to either then write and set the flareclusterer in code and same with the maptips (or at least write them as data template in XAML and load them in code). This is quite a big overhead in terms of effort. If I had less than 1000 features then I could have declared everthing in a few lines XAML. Is there any chance the max records property could actually go on the feature layer instead. It would make things so much easier.


Hi Mark,

We�??re working on some enhancements in Beta 2 that will make the Service property on a local layer settable and therefore by defining a local service as a resource in XAML then setting the service property, the service startup will be handled behind the scenes. This will limit having to write everything programmatically when setting the MaxRecords property.

Cheers

Kerrie
0 Kudos