This repository was archived by the owner on Sep 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Vitor Dino
committed
Sep 18, 2018
1 parent
1e11806
commit ddab7e8
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/campus-online-frontend/src/components/Map/index.js
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,40 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import ReactMapboxGl, {Layer, Feature} from 'react-mapbox-gl' | ||
import {colors} from '../../constants' | ||
|
||
const Placeholder = styled.div` | ||
background: ${colors.base}; | ||
` | ||
const RenderPlaceholder = ({className}) => <Placeholder className={className}/> | ||
const factory = (...args) => (typeof ReactMapboxGl === 'function' | ||
? ReactMapboxGl(...args) | ||
: RenderPlaceholder | ||
) | ||
|
||
const UnstyledMapBase = factory({ | ||
accessToken: 'pk.eyJ1Ijoidml0b3JkaW5vIiwiYSI6ImNqbTdmM2o5czB2YWIzcW4zdjE3M2ozZzcifQ.HWDJY3_QSQ6ytC0hGQ_Fcg', | ||
scrollZoom: false, | ||
}) | ||
|
||
const mapStyle = 'mapbox://styles/mapbox/dark-v9' | ||
|
||
const MapBase = styled(UnstyledMapBase)` | ||
.mapboxgl-ctrl-logo, .mapboxgl-ctrl-attrib{ | ||
display: none; | ||
} | ||
` | ||
|
||
const Map = ({coordinates, zoom = [12, 16], ...props}) => ( | ||
<MapBase center={coordinates} zoom={zoom} {...props} style={mapStyle}> | ||
<Layer | ||
type='symbol' | ||
id='marker' | ||
layout={{'icon-image': 'circle-stroked-15'}} | ||
> | ||
<Feature coordinates={coordinates}/> | ||
</Layer> | ||
</MapBase> | ||
) | ||
|
||
export default Map |