-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2a4bc1
commit f95e299
Showing
10 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ export default defineConfig({ | |
}, | ||
], | ||
hash: true, | ||
workerLoader: {}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './map'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Map } from '@pansy/react-mapbox-gl'; | ||
|
||
export default () => { | ||
return ( | ||
<div style={{ height: 500 }}> | ||
<Map /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Map } from './map'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
import { Map as Mapbox } from 'mapbox-gl'; | ||
import mapboxgl, { Map as Mapbox } from 'mapbox-gl'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import 'mapbox-gl/dist/mapbox-gl.css'; | ||
|
||
import MapboxWorker from 'mapbox-gl/dist/mapbox-gl-csp-worker'; | ||
|
||
// @ts-ignore | ||
mapboxgl.workerClass = MapboxWorker; | ||
|
||
import { FC } from 'react'; | ||
|
||
export const Map: FC = () => { | ||
return <div></div>; | ||
const container = useRef<HTMLDivElement>(null); | ||
const [map, setMap] = useState<Mapbox>(); | ||
|
||
useEffect(() => { | ||
if (!container.current) { | ||
return; | ||
} | ||
|
||
console.log(container.current); | ||
|
||
const map = new Mapbox({ | ||
container: container.current, | ||
zoom: 3, | ||
center: [7.5, 58], | ||
style: 'mapbox://styles/mapbox/light-v10', | ||
accessToken: | ||
'pk.eyJ1IjoiYmVpamluZ3NlbnNvcm8iLCJhIjoiY2wzNDhwMGU2MDAxdzNkbXB2eG5qcGJ4bSJ9.9YrZb00BwBNTsfMTdgj-oA', | ||
}); | ||
|
||
setMap(map); | ||
}, []); | ||
|
||
return <div ref={container} style={{ height: '100%', width: '100%' }} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'mapbox-gl/dist/mapbox-gl-csp-worker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters