Arcgis mapview issue with anywidget: [esri.views.MapView] #container element not found #271
-
Hi All, anyone has any idea how to solve this? I tried to use DOMContentLoaded to wait for the HTML to be loaded, still no luck. Thank you. import anywidget
import solara
class fake_widget(anywidget.AnyWidget):
# Widget front-end JavaScript code
_esm = """
import Map from "https://js.arcgis.com/4.27/@arcgis/core/Map.js";
import MapView from "https://js.arcgis.com/4.27/@arcgis/core/views/MapView.js";
export function render(view) {
//map holder
const container = document.createElement("div");
container.setAttribute("id","viewDiv")
var map = new Map({
basemap: "topo-vector"
});
var view_map = new MapView({
container:"viewDiv",
map: map
});
view.el.appendChild(container);
}
"""
@solara.component
def Page():
with solara.Column():
fake_widget.element()`
**error: [esri.views.MapView] #container element with id 'viewDiv' not found** |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @icduck, If you put a timeout on drawing the map, so that the container is added in before the map is appended to it, the map loads in. However after that you run into some other weirdness, with some FBO element resizing constantly, and your map flying beyond the screen quite rapidly. I'm not sure why this happen, perhaps you have some idea. So I did something like function makeMap(){
var map = new Map({
basemap: "topo-vector"
});
var view_map = new MapView({
container:"viewDiv",
map: map
});
}
view.el.appendChild(container);
setTimeout(makeMap, 100); |
Beta Was this translation helpful? Give feedback.
Hi @icduck,
If you put a timeout on drawing the map, so that the container is added in before the map is appended to it, the map loads in. However after that you run into some other weirdness, with some FBO element resizing constantly, and your map flying beyond the screen quite rapidly. I'm not sure why this happen, perhaps you have some idea.
So I did something like