hi sir,
in my distance function, it try to use the same function as it is in the samples.
but by the end of the code, this is the line where drawing of line and points must be visible:
Map1.DynamicOverlay.Redraw();
in my case, i use CustomOverlay not dynamic, so i don't have the function of redraw, the code is working and giving true results, but it is still invisble.
this is my code:
LayerOverlay layerOverlay1 = (LayerOverlay)Map1.CustomOverlays["ShapeOverlay"];
InMemoryFeatureLayer pointShapeLayer = (InMemoryFeatureLayer)layerOverlay1.Layers["pointShapeLayer"];
Feature newPoint = new Feature(e.Position);
InMemoryFeatureLayer lineShapeLayer = (InMemoryFeatureLayer)layerOverlay1.Layers["lineShapeLayer"];
if (ViewState["StartPoint"] == null)
{
pointShapeLayer.InternalFeatures.Clear();
lineShapeLayer.InternalFeatures.Clear();
}
pointShapeLayer.InternalFeatures.Add(newPoint.Id, newPoint);
if (ViewState["StartPoint"] != null)
{
PointShape startPoint = (PointShape)ViewState["StartPoint"];
MultilineShape line = startPoint.GetShortestLineTo(e.Position, GeographyUnit.DecimalDegree);
Feature lineFeature = new Feature(line);
string distanceValue = String.Format("{0} Mile", line.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Mile).ToString("N2"));
lineShapeLayer.InternalFeatures.Add(lineFeature.Id, lineFeature);
CloudPopup popup;
if (Map1.Popups.Contains("DistancePopup"))
{
popup = (CloudPopup)Map1.Popups["DistancePopup"];
popup.Position = e.Position;
popup.ContentHtml = distanceValue;
popup.IsVisible = true;
}
else
{
popup = new CloudPopup("DistancePopup", e.Position, distanceValue);
Map1.Popups.Add(popup);
popup.AutoSize = true;
}
ViewState["StartPoint"] = null;
}
else
{
ViewState["StartPoint"] = e.Position;
if (Map1.Popups.Contains("DistancePopup"))
{
Map1.Popups["DistancePopup"].IsVisible = false;
}
}
//Map1.DynamicOverlay.Redraw();
and i have adding those 2 layers using this code:
LayerOverlay layerOverlay33 = new LayerOverlay("ShapeOverlay");
InMemoryFeatureLayer pointShapeLayer = new InMemoryFeatureLayer();
pointShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Red, 8);
pointShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
InMemoryFeatureLayer lineShapeLayer = new InMemoryFeatureLayer();
lineShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.StandardColors.Red, 3));
lineShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
layerOverlay33.Layers.Add("pointShapeLayer", pointShapeLayer);
layerOverlay33.Layers.Add("lineShapeLayer", lineShapeLayer);
Map1.CustomOverlays.Add(layerOverlay33);