Bart,
I can now draw and delete both Polylines and Routes, but this introduced a new issue for me. The tag strings show for the Polylines I draw, but not for the Route Polylines that I add to the Polylines collection, and once I add the Route Polylines, any regular Polyline I add after that does not show it's tag string.
Below are 2 ways I've tested drawing routes by adding the route polyline to the polylines collection. They are very similar and behave the same way in regards to the tag strings. When you hover over the "route" polyline, the mouse changes, but no tag string is displayed and the line doesn't change to the hover color.
procedure TMainForm.btnRouteClick(Sender: TObject);
var Route: TRoute;
WayPoints: TStringList;
begin
WebGMaps1.Directions.Clear;
WayPoints:=TStringlist.Create;
WebGMaps1.GetDirections(32.7766642,-96.7969879,31.7618778,-106.4850217, // dallas to elpaso
True, tmDriving, usImperial, lnEnglish, {AvoidHwys}False, {AllowTollroads}False, WayPoints, {OptimizeWayPoints}False);
if WebGMaps1.Directions.Count>0 then
begin
Route := WebGMaps1.Directions[0]; // initial route
Route.Polyline.Color:=clBlack;
Route.Polyline.HoverColor:=clBlue;
Route.Polyline.TagString:='Route 1';
WebGmaps1.Polylines.Add(True,False,False,nil,Route.Polyline.Path, clAqua, 100, 4, True,RouteIDX);
WebGMaps1.PolygonLabel.Visible:=True; // allows hover hints on routes
// Route.Free;
end;
if WayPoints<>nil then
FreeAndNil(Waypoints);
end;
-- Below is method using a TPolylineItem -------------------------------
procedure TMainForm.btnRouteClick(Sender: TObject);
var Route: TRoute;
Pol: TPolylineItem;
WayPoints: TStringList;
begin
WebGMaps1.Directions.Clear;
WayPoints:=TStringlist.Create;
WebGMaps1.GetDirections(32.7766642,-96.7969879,31.7618778,-106.4850217, // dallas to elpaso
True, tmDriving, usImperial, lnEnglish, {AvoidHwys}False, {AllowTollroads}False, WayPoints, {OptimizeWayPoints}False);
if WebGMaps1.Directions.Count>0 then
begin
Route := WebGMaps1.Directions[0]; // initial route
Pol:=WebGmaps1.Polylines.Add(True,False,False,nil,Route.Polyline.Path, clAqua, 100, 4, True,RouteIDX);
Pol.Polyline.Color:=clBlack;
Pol.Polyline.HoverColor:=clBlue;
Pol.Polyline.TagString:='Route 1';
WebGMaps1.PolygonLabel.Visible:=True; // allows hover hints on routes
// Route.Free;
end;
if WayPoints<>nil then
FreeAndNil(Waypoints);
end;
Thanks for any insight you have on this.
Eric