Hello,
I am using the World Map Kit alongside the Map Suite Desktop Control and was wondering if someone had an example of how to code a progress bar or an indicator that shows the map is in the process of drawing?
Hello,
I am using the World Map Kit alongside the Map Suite Desktop Control and was wondering if someone had an example of how to code a progress bar or an indicator that shows the map is in the process of drawing?
Hi, Steve
First of all, you’ve mentioned that you’re using World Map Kit alongside the Desktop Control, so I’m guessing that you’re trying to use WorldMapKitWmsOverlay of Desktop Edition to display the map data. If that’s the case, I’m sorry to tell you that WorldMapKitWmsOverlay doesn’t support drawing progress changing indication. For the entire world map data are consumed at the server side, by the World Map Kit Server, and at the client side, Map Control is just responsible for sending web requests and processing the responses, and providing other advanced features, like TileCaching etc.
On the contrary, if you’re using Layers that inherits from FeatureLayer, that’s a different case. You can get the count of both the processed features and the unprocessed features by registering the DrawingProgressChanged event of a FeatureLayer in your application. In the passed-in event argument e, you can find the all the information of the drawing process. You can even stop drawing by setting the property Cancel to true.
Any further questions please let us know and we’ll do our best to help you.
Thanks a lot.
James
James,
Thanks for that information. I am not using the WorldMapKitWMSOverlay. I am using the World Map Kit SDK and have the data residing locally. Could you provide a code sample that shows how one might setup this DrawingProgressChanged event to update a progress bar or a busy indicator?
Hi, Steve
If you’re trying to use WorldMapKitRenderLayer which directly inherits from Layer, I’m sorry to tell you that when rendering the ShapefileFeatureLayers in the Layer, we can’t get the information of how the features are being drawn, but the good news is, we can find a workaround of this problem. Since you’ve got the code of WorldMapKitRenderLayer, you can simply add an event similar to DrawingProgressChanged event, and in the DrawCore method of Layer, add a few lines of code that raises this event.
Below is a sample of the source code we add to the DrawCore method, and the definition of the new event argument. And the attached file is a sample project shows how to update a progress bar by using WorldMapKitLayerDrawn.
WorldMapKitRenderLayer modification:
1. Add a public event announcement in the class:
public event EventHandler<WorldMapKitLayerDrawnEventArgs> WorldMapKitLayerDrawn;
2. Modify the DrawCore method:
2.1 Add these two parameters between line 3049 and 3051:
int layerCount = candidateLayerNames.Count;
int layerDrawn = 0;
2.2 After each layer is drawn, raise the event like this:
layerDrawn++;
WorldMapKitLayerDrawnEventArgs args = new WorldMapKitLayerDrawnEventArgs(layerCount, layerDrawn, layer.Name);
OnWorldMapKitLayerDrawn(args);
Event arguments definition:
public class WorldMapKitLayerDrawnEventArgs : ProgressChangedEventArgs
{
private int layerCount;
private int drawnLayerCount;
public int LayerCount
{
get { return layerCount; }
}
public int LayerDrawn
{
get { return drawnLayerCount; }
}
public WorldMapKitLayerDrawnEventArgs(int layerCount, int layerDrawn, object userState)
: base(layerCount * 100 / layerDrawn, userState)
{
this.layerCount = layerCount;
this.drawnLayerCount = layerDrawn;
}
}
Let me know if you have questions,
Thanks,
James
LayerDrawnIndicationSample.zip (10.9 KB)