File tree Expand file tree Collapse file tree 5 files changed +18
-28
lines changed
demo-app/src/jsMain/resources
maplibre-compose/src/jsMain/kotlin/org/maplibre/compose/map
maplibre-js-bindings/src/commonMain/kotlin/org/maplibre/kmp/js Expand file tree Collapse file tree 5 files changed +18
-28
lines changed Original file line number Diff line number Diff line change 55 < meta charset ="UTF-8 " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > MapLibre Compose demo app</ title >
8- < link
9- rel ="stylesheet "
10- href ="
https://unpkg.com/[email protected] /dist/maplibre-gl.css "
11- />
128 < style >
139 html ,
1410 body {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -164,21 +164,7 @@ androidMain.dependencies {
164164
165165 Web support is not yet at feature parity with Android and iOS. Check the [status table](index.md#status) for more info.
166166
167- For Web, you'll additionally need to add the MapLibre CSS to your page. The
168- easiest way to do this is via the CDN:
169-
170- ``` html title="index.html"
171- <!DOCTYPE html>
172- <html lang =" en" >
173- <head >
174- <link
175- rel =" stylesheet"
176- href =" https://unpkg.com/maplibre-gl@{{ gradle.maplibre_js_version }}/dist/maplibre-gl.css"
177- />
178- <title >Example Map</title >
179- </head >
180- </html >
181- ```
167+ There are no longer any special steps required to use MapLibre Compose on Web.
182168
183169## Set up Desktop (JVM)
184170
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import co.touchlab.kermit.Logger
1616import kotlinx.browser.document
1717import org.maplibre.compose.style.BaseStyle
1818import org.maplibre.compose.style.SafeStyle
19+ import org.maplibre.kmp.js.getVersion
1920import org.w3c.dom.HTMLElement
2021
2122@Composable
@@ -55,7 +56,19 @@ internal fun WebMapView(
5556
5657 WebElementView (
5758 modifier = modifier.onGloballyPositioned { maybeMap?.resize() },
58- factory = { document.createElement(" div" ).unsafeCast<HTMLElement >() },
59+ factory = {
60+ document.createElement(" div" ).unsafeCast<HTMLElement >().apply {
61+ appendChild(
62+ document.createElement(" link" ).apply {
63+ setAttribute(" rel" , " stylesheet" )
64+ setAttribute(
65+ " href" ,
66+ " https://unpkg.com/maplibre-gl@${getVersion()} /dist/maplibre-gl.css" ,
67+ )
68+ }
69+ )
70+ }
71+ },
5972 update = { element ->
6073 val map =
6174 maybeMap
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ import org.w3c.dom.TouchEvent
88import org.w3c.dom.events.MouseEvent
99import org.w3c.dom.events.WheelEvent
1010
11+ /* * https://maplibre.org/maplibre-gl-js/docs/API/functions/getVersion/ */
12+ public external fun getVersion (): String
13+
1114/* * [Map](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/) */
1215public external class Map public constructor(options : MapOptions ) {
1316 public var repaint: Boolean
You can’t perform that action at this time.
0 commit comments