hi i have created marker with inmemoryfeaturelayer and inmemorymarkeroverlay and this code is working fine all marker is created very well
but i have now one thing to do that is to create lines between all these markers at run time . basically i wants to attached all these markers with line draw i dont have any idea ho to achieve this please help me
this is my sample code for marker which is working fine but i only need to do now is to draw lines between all these markers.
thanks in advanced.
InMemoryFeatureLayer myData = new InMemoryFeatureLayer();
new Feature(Convert.ToDouble(Long),
Convert.ToDouble(Lat));
myData.EditTools.Add(myFeature);
InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay("MarkerOverlay" + users.nId);
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.ContentHtml = contentHtml.ToString();
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Width = 250;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Height = 290;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.IsVisible = false;
markerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.AutoPan = true;
markerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.CustomOverlays.Add(markerOverlay);
Inmemory feature on all markers draw line through between all markers
can anybody please answer
Hi Raja,
Draw lines should means you need to add multiply lineshape between them.
So you need to create a function for calculate all the lines between the marker coordinates, then set style for line in target layer and add all the new features into it.
Regards,
Don
basically i wants to do this
if there is 3 markers at different locations i wants to draw a line that is show path i have attached a diagram please look at
i dont have any idea how to do this please can you give me a sample code of this it would be very help full thanks.
Hi Raja,
It looks your missed your image.
The code as below wish be helpful:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PointShape marker1 = new PointShape(0, 0);
PointShape marker2 = new PointShape(12, 8);
PointShape marker3 = new PointShape(15, 15);
Collection<PointShape> points = new Collection<PointShape>();
points.Add(marker1);
points.Add(marker2);
points.Add(marker3);
Collection<LineShape> lines = getPath(points);
InMemoryFeatureLayer linesLayer = new InMemoryFeatureLayer();
linesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.Black, 2, true);
linesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
foreach (LineShape line in lines)
{
linesLayer.InternalFeatures.Add(new Feature(line));
}
Map1.DynamicOverlay.Layers.Add(linesLayer);
Map1.MapUnit = GeographyUnit.DecimalDegree;
Map1.CurrentExtent = new RectangleShape(-10, 30, 30, -10);
}
}
public Collection<LineShape> getPath(Collection<PointShape> points)
{
Collection<LineShape> lines = new Collection<LineShape>();
PointShape previousPoint = null;
foreach (PointShape point in points)
{
if (previousPoint != null)
{
Vertex startVertex = new Vertex(previousPoint);
Vertex endVertex = new Vertex(point);
LineShape line = new LineShape(new Collection<Vertex>() { startVertex, endVertex });
lines.Add(line);
}
previousPoint = point;
}
return lines;
}
Regards,
Don
This is working fine you are amazing!
Hi Raja,
I am glad to hear that works.
Regards,
Don
hi don
i have one more questions related to this topic!
can i make linestyle clickable and make it bold from where user connect
basically if a line is click from start point and end point i wants to make line bold and change the color can i do that?
thanks in advance and please send me sample code thanks
reply please
Hi Raja,
I am sorry but our line is not clickable.
You can only get the clicked point by mapclick event, then do spatial query to find the nearest line, then implement your custom logic here.
I think you can choose another inmemory feature layer as highlight layer, then put the target line there.
And I am sorry we don’t have an sample for that, but you can visit our samples to get more detail help on APIs.
Regards,
Don