# Importing a map (that is not a function)

**URL:** <https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149>\
**Category:** Uncategorized\
**Created:** [April 25, 2020, 2:43pm UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149 "2020-04-25T14:43:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 25, 2020, 2:43pm UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/1 "2020-04-25T14:43:23Z")

</div>

I am trying to import a map into another notebook. I’ve seen [Fil](https://observablehq.com/d/369db1eb34ba5e3e) and [Tom](https://observablehq.com/@tmcw/map) do this successfully for maps that are written as functions. To make the imported map render, they then call the function [if that’s the correct term] in a new cell: `map()`

How can it be done where the map is not a function?

Here’s a notebook where I appear to have correctly imported a map that is created in another notebook, but it’s not rendering (not for me, at least):

> **[Importing a Map](https://observablehq.com/d/a0daf20399d5b53d)**
>
> An Observable notebook by Aaron Kyle Dennis.

Seems I am missing a step…

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 25, 2020, 5:24pm UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/2 "2020-04-25T17:24:56Z")

</div>

Got it with `viewof` :

`viewof nepal_admin_map_oknp_rendered = nepal_admin_map_oknp`

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [April 25, 2020, 7:00pm UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/3 "2020-04-25T19:00:34Z")

</div>

I don’t think you want viewof here—the thing you’re importing isn’t a view.

It seems to work for me out of the box. Does this not work for you?

> **[Importing a Map](https://observablehq.com/d/1c5ddb8bac76a280)**
>
> An Observable notebook by Mike Bostock.

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 25, 2020, 9:46pm UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/4 "2020-04-25T21:46:34Z")

</div>

Thanks Mike.

No - It’s still not working for me, but I must assume this is b/c my current Internet connection is so poor that even loading the forum takes 30 seconds to a minute ☹

Weird that the `viewof` approach renders immediately!

Thanks for checking in and for the guidance. I noticed that the `viewof` approach wouldn’t allow controls to toggle back on when I tried this with a Leaflet map. I was going to follow up by posting console errors… just tackling a few family obligations first!

Thanks again!

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 26, 2020, 12:40am UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/5 "2020-04-26T00:40:58Z")

</div>

Nope - When I try it out of the box, I get an SVG element:

 ![import_svg-element](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/2/20052dfde24565db16b7c600f09bc5396dbb64f4.png)

> **[Importing a Map](https://observablehq.com/d/a0daf20399d5b53d)**
>
> An Observable notebook by Aaron Kyle Dennis.

I just updated the notebook. Looks the same as yours, but I am not getting the map.

**EDIT:** Not sure what’s up, but when I reload the notebook it works. When I start messing with things in the notebook without reloading, I get the SVG element output shown above.

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [April 26, 2020, 1:28am UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/6 "2020-04-26T01:28:08Z")

</div>

That’s strange—I can’t reproduce that error. I’d expect to see `SVGSVGElement` if you reference an SVG element that’s already displayed somewhere else in the notebook. Is it possible that as part of your “messing with things” that you’re trying to display `nepal_admin_map_oknp` in more than one place?

---

<div class="post-metadata">

**Author:** ![aaronkyle](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/aaronkyle/32/8106_2.png) [@aaronkyle](https://talk.observablehq.com/u/aaronkyle)\
**Post date:** [April 26, 2020, 11:24am UTC](https://talk.observablehq.com/t/importing-a-map-that-is-not-a-function/3149/7 "2020-04-26T11:24:40Z")

</div>

Maybe you can reproduce just by adding in `viewof` and then removing it.

I encountered that error originally when failing to import the notebook as a function. I kept the notebook open and re-ran the cell after just calling the imported variable on its own. I then tinkered and read through the tutorials till I got to ‘viewof’, plugged it in, and the map rendered instantly. I assumed that I just had to ‘re-render’ the variable, and that some magic behind ‘viewof’ was responsible for this.

It may _seriously_ also have to do with my Internet connection. I am experiencing other weird behavior.
