Hi,
I tried loading a 29 MB kml file on to the map. It does get displayed, but takes a very long time. I did not have problem with smaller kml files (around 500 kb). I use the following function to load kml files
public
void
LoadKMLFile(
string
strFilename)
{
try
{
string
kmlFile = strFilename;
KmlFeatureLayer kmlLayer =
new
KmlFeatureLayer(kmlFile);
kmlLayer.FeatureSource.Projection = proj4;
kmlLayer.StylingType = KmlStylingType.StandardStyle;
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle =
new
AreaStyle(
new
GeoPen(GeoColor.GetRandomGeoColor(200, RandomColorType.All)),
new
GeoSolidBrush(GeoColor.GetRandomGeoColor(200, RandomColorType.All)));
//kmlLayer.Transparency = 100;
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle =
new
LineStyle(
new
GeoPen(GeoColor.GetRandomGeoColor(200, RandomColorType.All), 5));
kmlLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle =
new
PointStyle(PointSymbolType.Circle,
new
GeoSolidBrush(GeoColor.GetRandomGeoColor(200, RandomColorType.All)), 10);
kmlLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay KMLOverlay =
new
LayerOverlay();
if
(strOverlayTimeConstant ==
"True"
)
{
KMLOverlay.Layers.Add(
"KmlLayer"
+ strdateTimeNow, kmlLayer);
wpfMap1.Overlays.Add(
"KmlOverlay"
+ strdateTimeNow, KMLOverlay);
wpfMap1.Overlays[wpfMap1.Overlays.Count - 1].Name =
"KmlOverlay"
+ strdateTimeNow;
wpfMap1.Overlays.MoveToTop(
"KmlOverlay"
+ strdateTimeNow);
}
else
{
uniqueNumOverlay = uniqueNumOverlay + 1;
strdateTimeNow = DateTime.Now.ToString(
"ddMMyyyyhhmmssffff"
) + uniqueNumOverlay.ToString();
KMLOverlay.Layers.Add(
"KmlLayer"
+ strdateTimeNow, kmlLayer);
wpfMap1.Overlays.Add(
"KmlOverlay"
+ strdateTimeNow, KMLOverlay);
wpfMap1.Overlays[wpfMap1.Overlays.Count - 1].Name =
"KmlOverlay"
+ strdateTimeNow;
wpfMap1.Overlays.MoveToTop(
"KmlOverlay"
+ strdateTimeNow);
}
// wpfMap1.Refresh();
kmlLayer.RequireIndex =
false
;
//kmlLayer.Open();
//if (kmlLayer.FeatureSource.GetCount() > 0)
//{
// wpfMap1.CurrentExtent = kmlLayer.GetBoundingBox();
//}
//kmlLayer.Close();
}
catch
(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
What can be done within the code to speed up the display? I suppose caching can be done, but would it be ok to cache smaller kml files too as I would be using the same function to load all kml files.
Thanks and regards,
Jacob