Skip to content

Commit

Permalink
cleaning mapboxgl support
Browse files Browse the repository at this point in the history
  • Loading branch information
yoiang committed Feb 24, 2022
1 parent ee2f0d4 commit 4ddde10
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/components/mapboxgl/Line.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GeoJSON } from 'geojson'
import { Expression, GeoJSONSource, GeoJSONSourceRaw } from 'mapbox-gl'
import React, { useContext, useEffect, useState } from 'react'
import { MapContext } from './Utility/MapContext'
import { MapContext } from './MapContext'

export interface Coordinates {
longitude: number
Expand Down
16 changes: 12 additions & 4 deletions src/components/mapboxgl/LocationInformationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const LocationInformationDialog = ({
showMouse,
mouseLongitude,
mouseLatitude,
showForCode,
showForCode
}: Props): React.ReactElement => {
return (
<div
Expand All @@ -34,21 +34,29 @@ export const LocationInformationDialog = ({
top: 0,
left: 0,
margin: 12,
borderRadius: 4,
borderRadius: 4
}}
>
<div>
<div>
Longitude: {longitude} | Latitude: {latitude} | Zoom: {zoom}
</div>
<div>{showForCode ? `- {"longitude": ${longitude}, "latitude": ${latitude}}` : null}</div>
<div>
{showForCode
? `- {"longitude": ${longitude}, "latitude": ${latitude}}`
: null}
</div>
</div>
{showMouse ? (
<div>
<div>
Mouse ~ Longitude: {mouseLongitude} | Latitude: {mouseLatitude}
</div>
<div>{showForCode ? `- {"longitude": ${mouseLongitude}, "latitude": ${mouseLatitude}}` : null}</div>
<div>
{showForCode
? `- {"longitude": ${mouseLongitude}, "latitude": ${mouseLatitude}}`
: null}
</div>
</div>
) : null}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/mapboxgl/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Line from './Line'
import LocationInformationDialog from './LocationInformationDialog'
import { MarkerMethods } from './Marker'
import { MinMax } from './Utility/LngLat'
import { MapContext } from './Utility/MapContext'

import { MapContext } from './MapContext'

interface Props {
accessToken: string
Expand Down Expand Up @@ -53,7 +54,7 @@ export const Map = ({
const [mapStyleIsLoaded, setMapStyleIsLoaded] = useState(false)
const [mouseLocation, setMouseLocation] = useState<LngLat | undefined>()
const [mouseLocationPause, setMouseLocationPause] = useState(false)
// const [markers, setMarkers] = useState<MarkersStore>({})

// TODO: only allows for one instance of a map, fix for future usage
mapboxgl.accessToken = accessToken

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/mapboxgl/Marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, {
useState
} from 'react'
import ReactDOM from 'react-dom'
import { MapContext } from './Utility/MapContext'
import { MapContext } from './MapContext'

export interface Coordinates {
longitude: number
Expand Down
25 changes: 0 additions & 25 deletions src/components/mapboxgl/Utility/Map.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/components/mapboxgl/Utility/Point.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Point } from 'mapbox-gl'

export const calculateDistanceSquared = (left: Point, right: Point): number => {
return (
(left.x - right.x) * (left.x - right.x) +
(left.y - right.y) * (left.y - right.y)
)
}
2 changes: 2 additions & 0 deletions src/components/mapboxgl/Utility/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './LngLat'
export * from './Point'
2 changes: 2 additions & 0 deletions src/components/mapboxgl/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { Map } from './Map'
export { Marker } from './Marker'
export { Line } from './Line'
export { MapContext } from './MapContext'
export * from './Utility'

0 comments on commit 4ddde10

Please sign in to comment.