Hello, I am trying to hide/show a single feature on a large layer but the refresh of the entire layer takes way too long. It takes up to 30 seconds to refresh the layer after turning off one single point… How can I speed this up?
public
void
HideFeatureOnLayer(
string
featureLayersGroupName,
string
featureLayerName,
ObservableCollection<mapfeature> features,
bool
doRefresh)
{
Validate.NotNullOrEmpty(
"featureLayersGroupName"
, featureLayersGroupName);
Validate.NotNullOrEmpty(
"featureLayerName"
, featureLayerName);
FeatureLayer featureLayer = GetFeatureLayerByName(featureLayerName);
if
(featureLayer !=
null
&& featureLayer.FeatureSource !=
null
)
{
featureLayer.FeatureSource.FeatureIdsToExclude.Clear();
foreach
(MapFeature feature
in
features)
{
featureLayer.FeatureSource.FeatureIdsToExclude.Add(feature.FeatureId);
}
featureLayer.FeatureSource.Open();
if
(doRefresh)
{
RefreshFeatureLayersGroup(featureLayersGroupName);
}
}
}
public
void
RefreshFeatureLayersGroup(
string
featureLayersGroupName)
{
Validate.NotNullOrEmpty(
"featureLayersGroupName"
, featureLayersGroupName);
if
(_mapControl.Overlays.Contains(featureLayersGroupName) && !IsRefreshSuppressed)
{
_mapControl.Overlays[featureLayersGroupName].Refresh();
}
}
Some more information:
The large layer is a shape file layer of wells. The layer can be only a few hundred or up to a few hundred thousand points. The layer that currently taking 30 seconds only has a 14000 points.
I have started to come up with a solution as we are very short on time. I was thinking I could break up the total number of points into groups of 500 or 1000 and create a different shape file for each group. Then I would build a manager that would know what layer a point belongs to so the refresh would only be 1 of the layers and not all of them when turning on or off a single feature. This could work for controlling the visibility of a single feature but it would not work for controlling the visibility of the entire group of points.
The number of points in a shape file could get up to 100,000 so we could have 100 shape file layers for these points. Would loading this many layers into the map be any slower then loading the one shape file with 100,000 points?