mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-04 17:32:56 +00:00
use store to access map object
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
<script lang="ts">
|
||||
import mapboxgl from 'mapbox-gl';
|
||||
import { GPXFile } from 'gpx';
|
||||
|
||||
export let file: GPXFile;
|
||||
export let map: mapboxgl.Map | null;
|
||||
import { map } from '$lib/stores';
|
||||
|
||||
$: if (map) {
|
||||
map.on('load', () => {
|
||||
console.log(map?.isStyleLoaded());
|
||||
map.addSource('gpx', {
|
||||
export let file: GPXFile;
|
||||
|
||||
$: if ($map) {
|
||||
$map.on('load', () => {
|
||||
$map.addSource('gpx', {
|
||||
type: 'geojson',
|
||||
data: file.toGeoJSON()
|
||||
});
|
||||
map.addLayer({
|
||||
$map.addLayer({
|
||||
id: 'gpx',
|
||||
type: 'line',
|
||||
source: 'gpx',
|
||||
|
Reference in New Issue
Block a user