WebOsmController constructor

WebOsmController(
  1. 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%';
      _frame!.setAttribute('srcdoc', htmlContent);
      _div.appendChild(_frame!);
      return _div;
    },
  );
}