gwidgets / gwty-leaflet

A GWT JsInterop wrapper for Leaflet.
Apache License 2.0
32 stars 14 forks source link

How to use an htmlpanel to initialize a map #2

Closed rakesh-roshan closed 8 years ago

rakesh-roshan commented 8 years ago

There are two APIs L.map to initialize map. One takes String id and other takes HTMLElement. How can I use HTMLPanel widget here. I think if you can provide HTMLElement class extending JavaScriptObject then HTMLPanel::getElement can be used here.

zak905 commented 8 years ago

If you take a look at the com.gwidgets.api.leaflet.elemental package, there in an HTMLElement class. You can do something like

HTMLPanel panel = new HTMLPanel("your html");

//...

RootPanel.get().add(panel);

HTMLElement mapElement = new HTMLElement();

mapElement .setInnerHTML(panel.getElement().getInnerHTML());

final Map map = L.map(mapElement , new MapOptions());
rakesh-roshan commented 8 years ago

Thanks a lot. I will try this.

zak905 commented 8 years ago

Can I close this issue?

rakesh-roshan commented 8 years ago

Yeah sure, I have not tried it, but I think it can be closed.

zak905 commented 8 years ago

Allright. Just a small correction with today's release:

mapElement.innerHTML = panel.getElement().getInnerHTML();

instead of:

mapElement .setInnerHTML(panel.getElement().getInnerHTML());
rakesh-roshan commented 8 years ago

Thanks a lot for the update