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
import MapboxGL, {LngLatLike, MercatorCoordinate} from 'mapbox-gl'; | |
import React, {useEffect, useState} from 'react'; | |
import {withMap} from 'react-mapbox-gl/lib-esm/context'; | |
import {FeatureCollection} from 'geojson'; | |
import * as THREE from 'three'; | |
import {GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader'; | |
export interface SpritePaint { | |
gltfPath: string; |
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
function handleDrag(eDown: Event) { | |
const targetEl = eDown.currentTarget; | |
targetEl.classList.add('dragging'); | |
// ~~~~~~~ Object is possibly 'null'. | |
// ~~~~~~~~~ Property 'classList' does not exist on type 'EventTarget'. | |
const dragStart = [ | |
eDown.clientX, eDown.clientY | |
// ~~~~~~~ 'clientX' does not exist on 'Event'. | |
// ~~~~~~~ 'clientY' does not exist on 'Event'. | |
]; |
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
#!/usr/bin/env python3 | |
"""Pretty-print GeoJSON in a slightly more compact way by putting coordinates on one line. | |
Compare: | |
[ | |
[ | |
37.23423, | |
79.23423 | |
], |
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
const inferKeys = <V extends {}>() => <K extends string>(x: Record<K,V>): Record<K,V> => x; | |
const INIT_VIEW = inferKeys<Partial<MapProps>>()({ | |
nyc: { | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
}, | |
sf: { |
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
const inferPick = <V extends {}>() => <K extends keyof V>(x: Pick<V, K>): Pick<V, K> => x; | |
const INIT_VIEW = inferPick<MapProps>()({ | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
style: "mapbox://styles/mapbox/streets-v9" | |
}); |
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
const INIT_VIEW: Pick<MapProps, 'center'|'zoom'|'pitch'|'bearing'|'style'> = { | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
style: "mapbox://styles/mapbox/streets-v9" | |
}; |
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
const INIT_VIEW: Partial<Props> = { | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
}; | |
export function render(): JSX.Element { | |
return ( | |
<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
export interface Props { | |
style: string | MapboxGl.Style; | |
center?: [number, number]; | |
zoom?: [number]; | |
maxBounds?: MapboxGl.LngLatBounds | FitBounds; | |
fitBounds?: FitBounds; | |
fitBoundsOptions?: FitBoundsOptions; | |
bearing?: [number]; | |
pitch?: [number]; | |
containerStyle?: React.CSSProperties; |
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
import * as React from 'react'; | |
import ReactMapboxGl from 'react-mapbox-gl'; | |
const Map = ReactMapboxGl({ | |
accessToken: '....', | |
}); | |
export function render(): JSX.Element { | |
return ( | |
<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
interface Order { | |
what: Product; | |
how: 'bitcoin' | 'usd'; | |
} | |
const order: Order = { | |
what: 'Macbook Air', | |
how: 'bitcoin' | |
}; | |
purchase(order.what); // ok |