Couldn't add PolyLines on Runtime

Hi,


In my project there is History option, gps coordinates saving to database and you can recall them from database and watch the it's route as animated on the map. I also want to draw paths with lines while you showing history. In this case i can use polylines (if i'm wrong please correct, i thought i can do that with polylines.), during design time i can add polylines using Polylines section in panel and it works fine, according to your manual i can add polylines during runtime with below code ;

var
 PolylineItem: TPolylineItem; 
begin 
PolylineItem := WebGMaps1.Polygons.Add; 
PolylineItem.Polyline.Width := 2;  
PolylineItem.Polyline.Path.Add(50, 2);  
PolylineItem.Polyline.Path.Add(52, 4);  
PolylineItem.Polyline.Path.Add(50, 4); 
 WebGMaps1.CreateMapPolyline(PolylineItem.Polyline);
end;


I'm adding a button to form and using above code but at var PolylineItem: TPolylineItem; line it returns [dcc32 Error] Unit1.pas(29): E2003 Undeclared identifier: 'TPolylineItem' error. I've tried to add one polyline during design time and after that tried above code but didn't helped. Polylines allready part of WebGmap component why it returns Undeclared Identifier, what am i missing here ?

Thanks in advance.

Hi,


Can you please make sure to include the UWebGMapsPolylines unit in the uses list of your project?

Hi Bart,

Adding UWebGMapsPolylines  to uses solved undeclared identifier error, now i'm having this error 
"[dcc32 Error] Unit1.pas(34): E2010 Incompatible types: 'TPolylineItem' and 'TPolygonItem'" is there any detailed tutorial about adding polylines on runtime ?

By the way when i open WebGmaps manual header says TPLANNER - TDBPLANNER.

Can you please change the line "WebGMaps1.Polygons.Add" to "WebGMaps1.Polylines.Add"?


Thank you for notifying about the errors in the WebGMaps manual, these will be corrected as soon as possible.

You can have a look at the WebGMapsDirections demo for an example on adding polylines to the map.

yes i've tried that,it doesn't return any error but it's not adding polylines too,i'll take a look to WebGmapsDirections demo to find out how does it work.


Thanks.

I've not been able to reproduce an issue with the above code (after changing Polygons to Polylines).

Can you please make sure that your map is placed on the correct position where the polyline is added? Have you tried zooming out?

after check the directions demo i just realised my code is not providing enough information to draw polyline (lat,lon etc.). Now editing my code according to directions demo, after that i believe it will work.


Thanks for your support.

Hi,


below code doesn't draw polylines to map, what am i missing ?



procedure TGeriTakip.Button1Click(Sender: TObject);
var
PolylineItem: TPolylineItem;
spdlmt,spd:integer;
begin
if (sorgu.Eof=False) then
  begin
sorgu.Close;
sorgu.Sql.Clear;
sorgu.Sql.Add('select * from araclar where cid=:cid');
sorgu.Params.ParamByName('cid').Value:=trim(kayitlar.Fields[2].asstring);
sorgu.Open;
spdlmt:=sorgu.fields[7].AsInteger;
harita.Markers[0].Latitude:=strtofloat(StringReplace(trim(kayitlar.Fields[4].asstring), '.', ',', [rfReplaceAll]));
harita.Markers[0].Longitude:=strtofloat(StringReplace(trim(kayitlar.Fields[5].asstring), '.', ',', [rfReplaceAll]));
harita.MapPanTo(harita.Markers[0].Latitude,harita.Markers[0].Longitude);
spd:=kayitlar.Fields[6].AsInteger;
if (spd>=spdlmt) then
begin
harita.Markers[0].Release;
harita.Markers.Add(strtofloat(StringReplace(trim(kayitlar.Fields[4].asstring), '.', ',', [rfReplaceAll])), strtofloat(StringReplace(trim(kayitlar.Fields[5].asstring), '.', ',', [rfReplaceAll])), Trim(kayitlar.Fields[3].asstring+' - '+kayitlar.Fields[6].asstring+' KM - '+kayitlar.Fields[7].asstring+' '+kayitlar.Fields[8].asstring), ikon+'ikaz_48.png', false, true, true, true, false, 0);
harita.Markers[0].MapLabel.text:='<font color=red><b>'+Trim(kayitlar.Fields[3].asstring+' - '+kayitlar.Fields[6].asstring+' KM - '+kayitlar.Fields[7].asstring+' '+kayitlar.Fields[8].asstring+' - Hız Limiti Aşımı');
PolylineItem:=harita.Polylines.Add;
PolylineItem.Polyline.Width:=2;
PolylineItem.Polyline.Color:=clRed;
PolylineItem.Polyline.Path.Add(strtofloat(StringReplace(trim(kayitlar.Fields[4].asstring), '.', ',', [rfReplaceAll])), strtofloat(StringReplace(trim(kayitlar.Fields[5].asstring), '.', ',', [rfReplaceAll])));
harita.CreateMapPolyline(PolylineItem.Polyline);
end//hız limiti aşılmışsa
else
begin
harita.Markers[0].Release;
harita.Markers.Add(strtofloat(StringReplace(trim(kayitlar.Fields[4].asstring), '.', ',', [rfReplaceAll])), strtofloat(StringReplace(trim(kayitlar.Fields[5].asstring), '.', ',', [rfReplaceAll])), Trim(kayitlar.Fields[3].asstring+' - '+kayitlar.Fields[6].asstring+' KM - '+kayitlar.Fields[7].asstring+' '+kayitlar.Fields[8].asstring), ikon+'arac_48.png', false, true, true, true, false, 0);
harita.Markers[0].MapLabel.text:=Trim(kayitlar.Fields[3].asstring+' - '+kayitlar.Fields[6].asstring+' KM - '+kayitlar.Fields[7].asstring+' '+kayitlar.Fields[8].asstring);
PolylineItem:=harita.Polylines.Add;
PolylineItem.Polyline.Width:=2;
PolylineItem.Polyline.Path.Add(strtofloat(StringReplace(trim(kayitlar.Fields[4].asstring), '.', ',', [rfReplaceAll])), strtofloat(StringReplace(trim(kayitlar.Fields[5].asstring), '.', ',', [rfReplaceAll])));
harita.CreateMapPolyline(PolylineItem.Polyline);
Caption:=kayitlar.Fields[4].asstring+' - '+kayitlar.Fields[5].asstring;
end;//hız limiti aşılmamışsa
kayitlar.Next;
  end;//eof değilse
end;///ana prosed?r

You are only adding 1 coordinate to the Polyline path.

Please note that, to be able to draw a line, the minimum amount of required coordinates is 2.

You are righti i've added two coordinates and it's fixed thanks alot.


Colors of polylines are so light i mean i'm using clyellow for under speed limit and clred for overspeed but they are not shine, is there any way to make those colors mor shiny.

i was looking for detailed example for polylines yesterday and just realised this PDF file's header is wrong too "http://www.tmssoftware.biz/Download/Manuals/TMS%20IntraWeb%20WebGMaps.pdf" it says DB Planer.

Also your new web site is much more beautiful than old version,the new version of your website is really awesome.

Thank you for your positive feedback about our new website design!

We will have the issue with the wrong header fixed.