Inconsistent Z order of polylines

Map (26.4 KB)

In my app I have a predefined route (polyline) for a vehicle to follow. As the vehicle travels, the app plots polyline segments behind it as the vehicle location changes. The problem I have encountered is that sometimes the Z order of the polylines is wrong. ie. The polyline that is painted over shows through when it shouldn't. See the supplied example image. A small section of black line has been rendered on top of the wider magenta line. This seems to happen randomly as the vehicle travels.
I have included a simple example app that produces this behaviour for investigation.


Thank you for your sample. I have investigated this here and applied a fix. The next version will introduce a property ZIndex, at TTMSFNCGoogleMapsPolyLine level. This is currently a Google Maps specific property, so you'll need to typecast the AddPolyLine base class to the Google Maps specific polyline class. This is necessary to access the ZIndex property. When the new version is available, the code from your sample will need to be changed to:

procedure TForm21.Timer1Timer(Sender: TObject);
  vLat, vLon: double;
  vPolyline: TTMSFNCGoogleMapsPolyline;
  vArray: TTMSFNCMapsCoordinateRecArray;
  // calculate next coordinates
  vLat := fCurrentPositionMarker.Latitude;
  vLon := fCurrentPositionMarker.Longitude;

  NextCoords(vLat, vLon);

    // set current position marker
    fCurrentPositionMarker.Latitude := vLat;
    fCurrentPositionMarker.Longitude := vLon;

    // recenter map >>>> still get the issue without re-centering <<<<
    Map.SetCenterCoordinate(fCurrentPositionMarker.Latitude, fCurrentPositionMarker.Longitude);

    // add a polyline segment
    SetLength(vArray, 2);
    vArray[0] := CreateCoordinate(fPreviousLatitude, fPreviousLongitude);
    vArray[1] := CreateCoordinate(vLat, vLon);

    vPolyline := TTMSFNCGoogleMapsPolyline(Map.AddPolyline(vArray));
    vPolyline.StrokeColor := TAlphaColorRec.Magenta;
    vPolyline.StrokeWidth := 10;
    vPolyline.StrokeOpacity := 1;
    vPolyLine.ZIndex := 1;

  fPreviousLatitude := vLat;
  fPreviousLongitude := vLon;

  lbNumPolylines.Text := Map.Polylines.Count.ToString;

We are currently adding new content and therefore, the latest release is currently frozen. Which means we are not going to release new updates/fixes until the new content is available. If the fix needed is urgent we can send you an incremental source update. Please contact us directly via email at with a link to this support question.

Thanks for that Pieter. Very much appreciated.
Any idea when the next release may be happening? I should be able to wait for the release as it is a minor visual issue.

The next release will take 2 to 4 weeks, depending on the research and progress.

Thanks. I have my fingers crossed for 2 weeks as our app should be in a major testing phase by then. :)

I cannot make promises, but I can send incremental source updates if necessary ;) Just ask and you shall receive.

Hi Pieter, I’ve changed my mind. Maybe you had better send the incremental source update for this one. I guess it also helps you out a bit for testing before a release.

Also, while I have your attention. Regarding the issue of the anchor point of a custom marker.

A colleague pointed out that there is a Google Maps API property in the interface called ‘anchor’ which states in the documentation ‘The position at which to anchor an image in correspondence to the location of the marker on the map. By default, the anchor is located along the center point of the bottom of the image.'

The documentation is here:

If there’s a chance that this property could be supported in the next update that would be great. If not, as a work around, I think if I grab the current map extents and the maps width and height I may be able to calculate the lat/lon location of the center of the custom marker. Thoughts?



I'll send the incremental source updates for Google Maps today. The anchoring is on our todolist, this is something that has been requested by users for a while now, as it sometimes does not make sense on how the image is positioned. So you can expect this in the next update. The incremental source update will not contain this improvement as this takes more time to investigate. Feedback based on the ZIndex behavior is greatly appreciated!

Hi Pieter. I’m still after that marker offset feature (see below). Any idea when the next release is coming out? (Soon I hope!)




We are currently preparing a new version. This will be available today or tomorrow.

1 Like