-
Hi! I'm looking to get something similar to the MapboxDraw example happening, but cannot seem to get the initial draw button to display. I've got let control = new MapboxDraw();
let map: Map | undefined;
let loaded: boolean;
$: if (map && loaded) {
map.addControl(control, "top-left");
} But that yields nothing in the top left of my map. I then attempted to move towards replicating one of the Control components: <script lang="ts">
import MapboxDraw from "@mapbox/mapbox-gl-draw";
import { mapContext } from "svelte-maplibre";
import maplibregl from "maplibre-gl";
import { onDestroy } from "svelte";
const { map } = mapContext();
export let position: maplibregl.ControlPosition = "top-left";
let control: MapboxDraw | null = null;
$: if ($map && !control) {
control = new MapboxDraw();
$map.addControl(control, position);
}
onDestroy(() => {
if ($map?.loaded() && control) {
$map.removeControl(control);
}
});
</script> But using that gave me the same (null) result. Can someone give me some pointers on what I may try? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Are you importing the CSS? That might be related https://github.com/mapbox/mapbox-gl-draw#css. Just adding If that doesn't help, I should be able to take a look tonight or tomorrow and see what's going on. |
Beta Was this translation helpful? Give feedback.
Are you importing the CSS? That might be related https://github.com/mapbox/mapbox-gl-draw#css. Just adding
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
at the top of your file should be sufficient.If that doesn't help, I should be able to take a look tonight or tomorrow and see what's going on.