I am trying to import a map into another notebook. I’ve seen Fil and Tom 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:
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):
Seems I am missing a step…
Got it with
viewof nepal_admin_map_oknp_rendered = nepal_admin_map_oknp
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?
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!
Nope - When I try it out of the box, I get an SVG element:
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.
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?
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.