Leventhal Map & Education Center

Bookmarklet to open an item directly in Allmaps. It checks if a Georeference Annotation is available and subsequently opens the item in the Allmaps Editor or Allmaps Viewer.

Installation

Drag the button below to the favorites bar of your browser in order to install this bookmarklet. Alternatively, you can copy the code below and paste it in the address or URL field of a new bookmark.

Open in Allmaps

Testing

Using the digital collections

Source code

javascript: (async function () {
    const id = window.location.href.match(/(commonwealth:[^?#]*)/)[1];
    const manifest = `https://collections.leventhalmap.org/search/${id}/manifest.json`;
    const encodedManifestUrl = encodeURIComponent(manifest);
    const editorBase = "https://editor.allmaps.org/#/collection?url=";
    const viewerBase = "https://viewer.allmaps.org/?url=";
    const annotationUrl = `https://annotations.allmaps.org/?url=${encodedManifestUrl}`;
    const response = await fetch(annotationUrl).then((response) => response.json());
    if (response.error) {
        window.location = editorBase + encodedManifestUrl
    } else {
        window.location = viewerBase + annotationUrl
    }
})()