Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1x | import mapboxgl from "mapbox-gl";
import React, { Component } from "react";
import { setCurrentLocationMarker } from "../../view/nearby/util/currentLocationMarker.util";
import { mountMapCenteredOnLocation } from "../../view/nearby/util/mapbox/mapboxUtils";
mapboxgl.accessToken =
"pk.eyJ1IjoiamFtZXNvbm55ZWhvbHQiLCJhIjoiY2p3NWoyamV0MTk1dDQ0cGNmdGZkenViMiJ9.TqDD3r62vlPzVgPnYjocsg";
export type LatLngCoords = number[];
interface Props {
currentLocation: LatLngCoords;
}
class Map extends Component<Props> {
private mapContainer: HTMLDivElement;
private map: mapboxgl.Map;
public componentDidMount() {
const { currentLocation } = this.props;
this.initializeMap(currentLocation);
}
public componentWillUnmount() {
this.map.remove();
}
public render() {
const style = {
height: 400,
position: "relative",
width: "100%"
};
// @ts-ignore
const map = <div style={style} ref={el => { this.mapContainer = el; }} />;
return (
<div>
{map}
<br />
<br />
</div>
);
}
private initializeMap(currentLocation: LatLngCoords) {
this.map = mountMapCenteredOnLocation(this.mapContainer, currentLocation);
this.map.on("load", () => {
setCurrentLocationMarker(this.map, currentLocation);
});
}
}
export default Map;
|