Skip to content

Commit

Permalink
[layer-leafet/maplibre] Slightly adapts #1483
Browse files Browse the repository at this point in the history
Details:
- Moves layers/leaflet.ts to layer-leaflet/lifecycle.ts
- Moves layers/maplibre.ts to layer-maplibre/lifecycle.ts
- Fixes weird "stderr" from MapLibre tests, by overriding the map's
  style
- Fixes overriding map style when calling bindMapLayer for MapLibre
- Removes unused import
  • Loading branch information
jacomyal committed Oct 29, 2024
1 parent cbb54fb commit 934a647
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/layer-maplibre/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Graph from "graphology";
import { Attributes } from "graphology-types";
import { LngLat, Map, MapOptions } from "maplibre-gl";
import { Sigma } from "sigma";
import { DEFAULT_SETTINGS } from "sigma/settings";

import { graphToLatlng, latlngToGraph, syncMapWithSigma, syncSigmaWithMap } from "./utils";

Expand Down Expand Up @@ -33,13 +32,13 @@ export default function bindMaplibreLayer(

// Initialize the map
const map = new Map({
...(opts?.mapOptions || {}),
container: mapContainerId,
style: "https://demotiles.maplibre.org/style.json",
center: [0, 0],
zoom: 1,
minPitch: 0,
maxPitch: 0,
...(opts?.mapOptions || {}),
});

// `stagePadding: 0` is mandatory, so the bbox of the map & Sigma is the same.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("@sigma/layer-leaflet", () => {
clean();
}).not.to.throw();
});
test<SigmaTestContext>("clean the map should reset sigma'settings to its previous value", ({ sigma }) => {
test<SigmaTestContext>("clean the map should reset sigma settings to its previous value", ({ sigma }) => {
const prevSettings = sigma.getSettings();

const { clean } = bindMapLayer(sigma);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ afterEach<SigmaTestContext>(async ({ sigma }) => {

describe("@sigma/layer-maplibre", () => {
test<SigmaTestContext>("calling clean function multiple times should work", ({ sigma }) => {
const { clean } = bindMapLayer(sigma);
const { clean } = bindMapLayer(sigma, { mapOptions: { style: undefined } });

expect(() => {
clean();
clean();
}).not.to.throw();
});
test<SigmaTestContext>("clean the map should reset sigma'settings to its previous value", ({ sigma }) => {
test<SigmaTestContext>("clean the map should reset sigma settings to its previous value", ({ sigma }) => {
const prevSettings = sigma.getSettings();

const { clean } = bindMapLayer(sigma);
const { clean } = bindMapLayer(sigma, { mapOptions: { style: undefined } });
const settings = sigma.getSettings();

clean();
Expand Down

0 comments on commit 934a647

Please sign in to comment.