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);
var
vLat, vLon: double;
vPolyline: TTMSFNCGoogleMapsPolyline;
vArray: TTMSFNCMapsCoordinateRecArray;
begin
// calculate next coordinates
vLat := fCurrentPositionMarker.Latitude;
vLon := fCurrentPositionMarker.Longitude;
NextCoords(vLat, vLon);
Map.BeginUpdate;
// 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;
Map.EndUpdate;
fPreviousLatitude := vLat;
fPreviousLongitude := vLon;
lbNumPolylines.Text := Map.Polylines.Count.ToString;
end;
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 support@tmssoftware.com 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.
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 google.map.Icon 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.'
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!