Skip to content

Commit

Permalink
fix(web): ensure the usage of maplibre-gl-js version 4.x.x, remove …
Browse files Browse the repository at this point in the history
…`_addStylesheetToShadowRoot` (maplibre#409)
  • Loading branch information
josxha authored and remax21 committed Sep 10, 2024
1 parent 78f3573 commit 4a65602
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
6 changes: 3 additions & 3 deletions example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="/favicon.png"/>

<!-- Maplibre -->
<script src='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.js'></script>
<link href='https://unpkg.com/maplibre-gl@latest/dist/maplibre-gl.css' rel='stylesheet' />
<!-- MapLibre -->
<script src='https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.js'></script>
<link href='https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.css' rel='stylesheet' />

<title>example</title>
<link rel="manifest" href="/manifest.json">
Expand Down
14 changes: 0 additions & 14 deletions maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
part of maplibre_gl_web;

//TODO Url taken from the Maptiler tutorial; use official and stable release once available
final _maplibreGlCssUrl =
'https://cdn.maptiler.com/maplibre-gl-js/v1.13.0-rc.4/mapbox-gl.css';

class MaplibreMapController extends MapLibreGlPlatform
implements MapLibreMapOptionsSink {
late html.DivElement _mapElement;
Expand Down Expand Up @@ -61,7 +57,6 @@ class MaplibreMapController extends MapLibreGlPlatform

@override
Future<void> initPlatform(int id) async {
await _addStylesheetToShadowRoot(_mapElement);
if (_creationParams.containsKey('initialCameraPosition')) {
var camera = _creationParams['initialCameraPosition'];
_dragEnabled = _creationParams['dragEnabled'] ?? true;
Expand Down Expand Up @@ -176,15 +171,6 @@ class MaplibreMapController extends MapLibreGlPlatform
}
}

Future<void> _addStylesheetToShadowRoot(html.HtmlElement e) async {
final link = html.LinkElement()
..href = _maplibreGlCssUrl
..rel = 'stylesheet';
e.append(link);

await link.onLoad.first;
}

@override
Future<CameraPosition?> updateMapOptions(
Map<String, dynamic> optionsUpdate) async {
Expand Down

0 comments on commit 4a65602

Please sign in to comment.