A JavaScript library for parsing and converting Geospatial Metadata.
npm install @wsdot/geospatial-metadata
import { toHtmlFragment } from "@wsdot/geospatial-metadata";
/**
* Gets a metadata XML document, converts it to an HTMLDocumentFragment,
* then appends the fragment to the document body.
* @param {string} url - Metadata URL.
* @returns {Promise}
*/
async function getMetadataHtml(url) {
const response = await fetch(url);
const xml = await response.text();
const frag = toHtmlFragment(xml);
document.body.append(frag);
}
// URL to retrieve XML metadata via ArcGIS Server.
const url = "https://data.wsdot.wa.gov/arcgis/rest/services/Shared/BridgeData/MapServer/2/metadata/";
getMetadataHtml(url).then(() => {
console.log(`Successfully added metadata from ${url}.`);
}, error => {
console.error(`Error adding metadata from ${url}`, error);
});