WebOsmController constructor
WebOsmController(
- String htmlContent
Implementation
WebOsmController(String htmlContent) {
//createHtml(id: );
mapId++;
// ui.platformViewRegistry.registerViewFactory(
// FlutterOsmPluginWeb.getViewType(), (int viewId) => _div);
mapIdMixin = mapId;
_div = web.document.createElement(
'div',
) as web.HTMLDivElement; //web.HTMLDivElement(); //html.DivElement()
_div.style.width = '100%';
_div.style.height = '100%';
ui.platformViewRegistry.registerViewFactory(
FlutterOsmPluginWeb.getViewType(mapId),
(int viewId) {
debugPrint("viewId : $viewId");
_div.id = 'osm_map_$mapIdMixin';
final idFrame = "frame_map_$mapIdMixin";
debugPrint(idFrame);
_frame = web.document.createElement("iframe") as web.HTMLIFrameElement
..id = idFrame
..style.width = '100%'
..style.height = '100%';
// Blob URLs stay same-origin. `srcdoc` becomes `about:srcdoc` under
// Flutter WASM COOP/COEP and breaks History.replaceState + JS interop.
final blob = web.Blob(
[htmlContent.toJS].toJS,
web.BlobPropertyBag(type: 'text/html'),
);
_frameUrl = web.URL.createObjectURL(blob);
_frame!.src = _frameUrl!;
_div.appendChild(_frame!);
return _div;
},
);
}