
com.gwidgets.api.leaflet.utils.LeafletResources Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwty-leaflet Show documentation
Show all versions of gwty-leaflet Show documentation
a JsInterop wrapper for the Leaflet js library
package com.gwidgets.api.leaflet.utils;
import com.google.gwt.core.client.GWT;
import elemental2.dom.DomGlobal;
import elemental2.dom.Element;
import elemental2.dom.HTMLLinkElement;
import elemental2.dom.HTMLScriptElement;
public class LeafletResources {
public static void whenReady(boolean debug, Element.OnloadFn function){
HTMLScriptElement leafletScript = (HTMLScriptElement) DomGlobal.document.createElement("script");
if (debug) {
leafletScript.src = GWT.getModuleName() + "/leaflet/leaflet-src.js";
} else {
leafletScript.src = GWT.getModuleName() + "/leaflet/leaflet.js";
}
leafletScript.type="text/javascript";
HTMLLinkElement leafletStyle = (HTMLLinkElement) DomGlobal.document.createElement("link");
leafletStyle.href=GWT.getModuleName()+"/leaflet/leaflet.css";
leafletStyle.rel="stylesheet";
DomGlobal.document.head.appendChild(leafletScript);
DomGlobal.document.head.appendChild(leafletStyle);
leafletScript.onload = function;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy