GEDCOM
The FamilyTree2.convertGedcomToFamilyMembers() method allows you to import GEDCOM file data directly into
Family Tree JS 2 and display it as a family tree.
FamilyTree2.convertGedcomToFamilyMembers(text, fieldBinding)
text— The raw GEDCOM file content as a string.-
fieldBinding— An object that maps GEDCOM tag names to your family tree node property names."NAME": "name" // Map GEDCOM "NAME" tag to the node's "name" property "BIRT_DATE": "dateOfBirth", // Map GEDCOM "1 BIRT 2 DATE" tag to the node's "dateOfBirth" property
Here is an example of how you can load a GEDCOM data:
-
Open a GEDCOM file using the File System Access API:
showOpenFilePicker()lets the user choose a.gedfile.- The file content is read as text.
-
Convert GEDCOM to Family Members:
let familyMembers = FamilyTree2.convertGedcomToFamilyMembers(text, fieldBinding); -
Load into the Family Tree:
familyTree.addFamilyMembers(familyMembers).draw(familyMembers[0].id);
Full Code Example:
Load GEDCOM Data in Family Tree JS 2
This example demonstrates:
- Opening a
.gedfile. - Mapping GEDCOM fields with
fieldBinding. - Converting to family members with
convertGedcomToFamilyMembers(). - Displaying the data in a Family Tree.