Skip to content

[Directus] GPX file import interface for geometry fields #21

Description

@wazolab

Context

The Directus CMS manages POIs with geometry fields displayed via the built-in map interface. Currently, users must manually draw geometry on the map. Many users have GPX files from GPS devices or route planners that they want to import as POI geometry.

A Ruby migration script already exists at db/migrate/20260176014838_gpx_to_geom.rb that converts GPX → GeoJSON (LineString/MultiLineString), but this is a one-time migration, not a user-facing tool.

Goal

Build a Directus interface extension (directus-extension-map-gpx) that wraps the built-in map interface for geometry fields, adding GPX file upload capability while preserving all existing map features (drawing, editing).

Features

  • Wraps built-in interface-map — reuses MapLibre GL + Mapbox Draw for full geometry drawing/editing
  • GPX upload zone (drag & drop / file input) below the map
  • Client-side GPX parsing using browser DOMParser (no server dependency)
    • Prefers <trk>/<trkseg>/<trkpt> (GPS traces) over <rte>/<rtept> (waypoints)
    • Removes consecutive duplicate points
    • Merges contiguous linestrings
    • Returns GeoJSON LineString or MultiLineString
  • Error handling for invalid GPX files (using Directus <v-notice>)
  • No extra map dependency — only bundles the GPX parser logic

Acceptance criteria

  • Build succeeds without errors
  • Extension appears in Directus interface selector as "Map (GPX)"
  • Assigning it to a geometry field shows the map with drawing tools
  • Uploading a valid GPX file parses it and displays the route on the map
  • Saving the item persists the GeoJSON geometry to the database
  • Invalid GPX files show an error notice
  • Manual geometry drawing/editing works (inherited from built-in map)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions