Read and edit the historical events of an OpenHistoricalMap node, way or relation.
An event is a relation tagged type=event, with event=*, name, start_date and optional
end_date, description, wikidata and source. The affected object is a member with
role=location.
import { EventsEditor, upload } from "@openhistoricalmap/events";
const editor = await EventsEditor.load({ type: "way", id: 201162207 }, { apiUrl: "/api/0.6" });
editor.events; // sorted by start_date
editor.add({ event: "fire", name: "Great fire", start_date: "1871-10-08" });
editor.update(123, { end_date: "1871-10-10" }); // empty value removes a tag
editor.remove(123); // deletes the relation, or only unlinks the object if it has other members
editor.toOsmChange(changesetId); // osmChange XML
await upload(editor, { authorization: "Bearer <token>", comment: "Add event" });upload creates a changeset, uploads one osmChange and always closes the changeset.
mountPanel(container, { editor, canEdit, uploadOptions, onDateClick }) renders the list and a
Bootstrap modal to add, edit and remove events. mountOhmWebsite({ map, type, id }) mounts it in
the element sidebar of the OHM website.
npm install
npm test
npm run build # dist/ohm-events.js, a single ES modulepython3 -m http.server 8765
# open http://localhost:8765/demo/The demo reads real data from openhistoricalmap.org and never uploads. Saving shows the
osmChange that would be sent. If the API is not reachable it uses demo/fixtures.js.
dist/ is committed, so it works without npm:
yarn add github:Rub21/ohm-events#v0.1.0