I have created a map that I now wish to embed in an HTML webpage.
Following Jeremy’s primer on embedding a notebook, I can get the whole page to render out beautify as follows:
<!DOCTYPE html>
<body>
<script type="module">
// Load the Observable runtime and inspector.
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
// Your notebook, compiled as an ES module.
import notebook from "https://api.observablehq.com/d/310b9c62aec0e434@462.js?v=3";
// Load the notebook, observing its cells with a default Inspector
// that simply renders the value of each cell into the provided DOM node.
new Runtime().module(notebook, Inspector.into(document.body));
</script>
Here’s a snapshot:
When I try, however, to render out only the map cell, things go haywire:
<!DOCTYPE html>
<body>
<div id="map"></div>
<script type="module">
// Load the Observable runtime and inspector.
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
// Your notebook, compiled as an ES module.
import notebook from "https://api.observablehq.com/d/310b9c62aec0e434@462.js?v=3";
// Load the notebook, observing its cells with a default Inspector
// that simply renders the value of each cell into the provided DOM node.
new Runtime().module(notebook, name => {
if (name === "map") {
return new Inspector(document.querySelector("#map"));
}
});
</script>
Specifically, tiles don’t load in, I can’t see the layer toggle, etc.
Here’s a snapshot:
The console gives me some warnings about cookies from wikimedia.org and CORS, as well as a message that Node cannot be found in the current page.
, but no errors.
Any insights into why I can’t properly render the cell and how to correct for it?