# Line patterns with markers do not work properly

**URL:** <https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217>\
**Category:** MapWinGIS\
**Created:** [January 21, 2022, 8:41am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217 "2022-01-21T08:41:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![frank2x460](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@frank2x460](https://mapwindow.discourse.group/u/frank2x460)\
**Post date:** [January 21, 2022, 8:41am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/1 "2022-01-21T08:41:26Z")

</div>

Hello,

since Version 5.2.4 creating linepattern with markers does not work predictable, sometimes the markers appear, sometime they do not.  
I verified it with the mapwingis examples app (see attachment) . The error occurs even with the newest version 5.3.0. Using 5.1.1.1 everything is fine.  
Please have a look at the code.

Thanks  
Frank

 ![error_linepattern_with_markers](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/665139129bded68c9a4a6ad89e0400264f00d1db.jpeg)

---

<div class="post-metadata">

**Author:** ![Henry](https://avatars.discourse-cdn.com/v4/letter/h/df705f/32.png) [@Henry](https://mapwindow.discourse.group/u/Henry)\
**Post date:** [January 21, 2022, 9:56am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/2 "2022-01-21T09:56:28Z")

</div>

I also encountered this problem. Looking forward to answer.

---

<div class="post-metadata">

**Author:** ![frank2x460](https://avatars.discourse-cdn.com/v4/letter/f/b5a626/32.png) [@frank2x460](https://mapwindow.discourse.group/u/frank2x460)\
**Post date:** [January 21, 2022, 11:22am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/3 "2022-01-21T11:22:40Z")

</div>

Hello,

after taking a look at the sourcecode is seems obvious, that in the constructor of CLineSegment (LineSegment.h) the “new” Properties are not or wrong initialized. After adding the missing initialization and recompiling the .ocx everything seems to work.

If someone could verify…?

> CLineSegment()  
> {  
> \_pUnkMarshaler = NULL;  
> \_lineType = lltSimple;  
> \_lineColor = RGB(0,0,0);  
> \_markerOutlineColor = RGB(120, 120, 120);  
> \_lineWidth = 1.0f;  
> \_lineStyle = dsSolid;  
> \_marker = dpsDiamond;  
> \_markerSize = 12;  
> \_markerInterval = 16;  
> \_markerOffset = 0.0f;  
> \_markerOrientation = lorParallel;  
> \_markerFlipFirst = VARIANT\_FALSE; // WRONG  
> \_markerIntervalIsRelative = VARIANT\_FALSE; //MISSING  
> \_markerOffsetIsRelative = VARIANT\_FALSE; //MISSING  
> \_markerAllowOverflow = VARIANT\_FALSE; //MISSING  
> gReferenceCounter.AddRef(idLineSegment);  
> }

Best Regards,  
Frank

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 21, 2022, 1:17pm UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/4 "2022-01-21T13:17:08Z")

</div>

Thanks Frank for also providing a potential fix.

@jerryfaust: Could you have a look. It seems OK to me.  
I’ve created [MWGIS-255](https://mapwindow.atlassian.net/browse/MWGIS-255) for this.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 21, 2022, 4:26pm UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/5 "2022-01-21T16:26:46Z")

</div>

Yes, I’ll review it this weekend.

Thank you, Frank.

Jerry.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [January 24, 2022, 3:00am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/6 "2022-01-24T03:00:21Z")

</div>

Ironically, it looks like those new internal variables (listed as MISSING) were first introduced in the 5.1.1.1 release, and none of them were ever pre-initialized, which of course would produce unpredictable results. It’s possible that a subsequent change further altered the behavior. Either way, it is appropriate to initialize them in the constructor as recommended.

Jerry.

---

<div class="post-metadata">

**Author:** ![josimar.alves](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@josimar.alves](https://mapwindow.discourse.group/u/josimar.alves)\
**Post date:** [March 3, 2022, 10:44pm UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/7 "2022-03-03T22:44:12Z")

</div>

Hi @jerryfaust and @pmeems,

I’m also getting a strange result if I use the arrow symbol in my user definined line.  
The arrow is drawing correctly but I can’t change the orientation. I want draw a red arrow from left to right, but it’s is drawing in other way from right to left.  
Here is my code:

```auto
with FWRF do begin
    mUtils := CoUtils.Create;
    mPattern := CoLinePattern.Create;
    mPattern.AddLine(mUtils.ColorByName (Black), 12.0, dsSolid);
    mPattern.AddLine(mUtils.ColorByName (Green), 8.0, dsSolid);
    mSegm := mPattern.AddMarker(dpsArrowLeft);
    mSegm.MarkerOrientation := lorParallel;
    mSegm.Marker := dpsArrowRight ;
    mSegm.MarkerFlipFirst := false;
    mSegm.Color := mUtils.ColorByName (Red);
    mSegm.MarkerSize := 15;
    mSegm.MarkerInterval := 30;
    mSegm.MarkerIntervalIsRelative := false;
    DefaultDrawingOptions.LinePattern := mPattern;
    DefaultDrawingOptions.UseLinePattern := true;
  end;

```

Do you know what I’m doing wrong?  
The line below start from left to right, but the array is drawing from right to left:

 ![image](https://global.discourse-cdn.com/free1/uploads/mapwindow1/original/1X/1093c7792f7e7425ec2d1f8c6419d6df101b30d8.jpeg)

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [March 9, 2022, 7:59am UTC](https://mapwindow.discourse.group/t/line-patterns-with-markers-do-not-work-properly/1217/8 "2022-03-09T07:59:36Z")

</div>

Can’t you just use  
`mSegm := mPattern.AddMarker(dpsArrowRight);`
