I'm using the TMSFNCGoogleMaps component (latest release TMS FNC Maps v3.6.0.2 | Friday, March 24, 2023).
I use the .LoadGPXFromFile function which works, the polylines are loaded properly.
So far I see, there is still no support for displaying labels in TMSFNCGoogleMaps or am I overlooking something?
I've tried to use the event OnCreateGPXTrack to access the data from the GPX import and get the required values for each "trk"-part .
Basically it works, I can access the nodes and the NodeName "name" is found as expected.
Example:
procedure TForm4.TMSFNCGoogleMaps1CreateGPXTrack(Sender: TObject; AEventData: TTMSFNCMapsGPXTrackEventData);
var i:Integer;
c:IDOMNodeList;
_name:String;
begin
if AEventData.Node.hasChildNodes then
begin
c:=AEventData.Node.childNodes;
for I := 0 to c.length-1 do
begin
if LowerCase(c.Item[i].nodeName)='name' then _name:=c.Item[i].nodeValue;
end;
end;
// Do something with _name
end;
In the GPX data looks like this:
...
trk>
name>Nauru FIR
type>FIR
extensions>
ogr:designator>ANAU</ogr:designator>
ogr:lower>0.0</ogr:lower>
/extensions>
trkseg>
trkpt lat="0.000090000089997" lon="160.000180000180023">
/trkpt>
trkpt lat="3.500013500013495" lon="160.000180000180023">
...
(had to remove the "<")
The problem is, c.Item[i].nodeValue is empty and not "Nauru FIR" as I expected.
Do you have any suggestion? Or do I have to parse the GPX File on my own to get the values?
By the way: a Centroid Property for Polylines/Polygones would be very nice.
Hi,
You refered to "Extra data from GPX files should be parsed manually. This is explained in the online doc:"
In the example is the following line:
HeartRate := StrToInt(NodeToString(FindNode(FindNode(AEventData.Node,
'extensions'), 'hr')));
Please be so kind and tell me, where to find the functions "NodeToString" and "FindNode".
Well, I found them in VCL.TMSFNCMaps, but I can't access them as they are not declared in the interface part.
We'll look into making these functions available publicly in a future version.
You can add both functions directly in your code like this:
function FindNode(const ANode: TTMSFNCMapsXMLDOMNode; const ANodeName: string): TTMSFNCMapsXMLDOMNode;
var
I: Integer;
rNode: TTMSFNCMapsXMLDOMNode;
begin
Result := nil;
for I := 0 to ANode.childNodes.length - 1 do
begin
rNode := ANode.childNodes[I];
if rNode.NodeName = ANodeName then
Result := rNode;
end;
end;
function NodeToString(ANode: TTMSFNCMapsXMLDOMNode): string;
begin
Result := '';
if not Assigned(ANode) then
Exit;
Result := ANode.firstChild.nodeValue;
end