mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-26 11:49:04 +01:00
exif/map tweaks
This commit is contained in:
parent
8dce8c4df4
commit
782f597db8
@ -7,27 +7,21 @@ import styles from './Exif.module.scss'
|
|||||||
const MAPBOX_ACCESS_TOKEN =
|
const MAPBOX_ACCESS_TOKEN =
|
||||||
'pk.eyJ1Ijoia3JlbWFsaWNpb3VzIiwiYSI6ImNqbTE2NHpkYjJmNm8zcHF4eDVqZzk3ejEifQ.1uwPzM6MSTgL2e1Hxcmuqw'
|
'pk.eyJ1Ijoia3JlbWFsaWNpb3VzIiwiYSI6ImNqbTE2NHpkYjJmNm8zcHF4eDVqZzk3ejEifQ.1uwPzM6MSTgL2e1Hxcmuqw'
|
||||||
|
|
||||||
const mapbox = (mapboxId, accessToken) => (x, y, z) => {
|
const retina =
|
||||||
const retina =
|
typeof window !== 'undefined' && window.devicePixelRatio >= 2 ? '@2x' : ''
|
||||||
typeof window !== 'undefined' && window.devicePixelRatio >= 2 ? '@2x' : ''
|
|
||||||
return `https://api.mapbox.com/styles/v1/mapbox/${mapboxId}/tiles/256/${z}/${x}/${y}${retina}?access_token=${accessToken}`
|
const mapbox = (mapboxId, accessToken) => (x, y, z) =>
|
||||||
}
|
`https://api.mapbox.com/styles/v1/mapbox/${mapboxId}/tiles/256/${z}/${x}/${y}${retina}?access_token=${accessToken}`
|
||||||
|
|
||||||
const providers = {
|
const providers = {
|
||||||
osm: (x, y, z) => {
|
osm: (x, y, z) => {
|
||||||
const s = String.fromCharCode(97 + ((x + y + z) % 3))
|
const s = String.fromCharCode(97 + ((x + y + z) % 3))
|
||||||
return `https://${s}.tile.openstreetmap.org/${z}/${x}/${y}.png`
|
return `https://${s}.tile.openstreetmap.org/${z}/${x}/${y}.png`
|
||||||
},
|
},
|
||||||
wikimedia: (x, y, z) => {
|
wikimedia: (x, y, z) =>
|
||||||
const retina =
|
`https://maps.wikimedia.org/osm-intl/${z}/${x}/${y}${retina}.png`,
|
||||||
typeof window !== 'undefined' && window.devicePixelRatio >= 2 ? '@2x' : ''
|
stamen: (x, y, z) =>
|
||||||
return `https://maps.wikimedia.org/osm-intl/${z}/${x}/${y}${retina}.png`
|
`https://stamen-tiles.a.ssl.fastly.net/terrain/${z}/${x}/${y}${retina}.jpg`,
|
||||||
},
|
|
||||||
stamen: (x, y, z) => {
|
|
||||||
const retina =
|
|
||||||
typeof window !== 'undefined' && window.devicePixelRatio >= 2 ? '@2x' : ''
|
|
||||||
return `https://stamen-tiles.a.ssl.fastly.net/terrain/${z}/${x}/${y}${retina}.jpg`
|
|
||||||
},
|
|
||||||
streets: mapbox('streets-v10', MAPBOX_ACCESS_TOKEN),
|
streets: mapbox('streets-v10', MAPBOX_ACCESS_TOKEN),
|
||||||
satellite: mapbox('satellite-streets-v10', MAPBOX_ACCESS_TOKEN),
|
satellite: mapbox('satellite-streets-v10', MAPBOX_ACCESS_TOKEN),
|
||||||
outdoors: mapbox('outdoors-v10', MAPBOX_ACCESS_TOKEN),
|
outdoors: mapbox('outdoors-v10', MAPBOX_ACCESS_TOKEN),
|
||||||
@ -35,23 +29,37 @@ const providers = {
|
|||||||
dark: mapbox('dark-v9', MAPBOX_ACCESS_TOKEN)
|
dark: mapbox('dark-v9', MAPBOX_ACCESS_TOKEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
class MapExif extends PureComponent {
|
class ExifMap extends PureComponent {
|
||||||
|
state = { zoom: 6 }
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
gps: PropTypes.object
|
gps: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zoomIn = () => {
|
||||||
|
this.setState({
|
||||||
|
zoom: Math.min(this.state.zoom + 3, 18)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { latitude, longitude } = this.props.gps
|
const { latitude, longitude } = this.props.gps
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Map
|
<Map
|
||||||
center={[latitude, longitude]}
|
center={[latitude, longitude]}
|
||||||
zoom={12}
|
zoom={this.state.zoom}
|
||||||
height={160}
|
height={160}
|
||||||
attribution={false}
|
attribution={false}
|
||||||
provider={providers['light']}
|
provider={providers['light']}
|
||||||
|
metaWheelZoom={true}
|
||||||
|
metaWheelZoomWarning={'META+wheel to zoom'}
|
||||||
>
|
>
|
||||||
<Marker anchor={[latitude, longitude]} payload={1} onClick={() => {}} />
|
<Marker
|
||||||
|
anchor={[latitude, longitude]}
|
||||||
|
payload={1}
|
||||||
|
onClick={this.zoomIn}
|
||||||
|
/>
|
||||||
</Map>
|
</Map>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -84,7 +92,7 @@ export default class Exif extends PureComponent {
|
|||||||
{iso && <span title="ISO">{iso}</span>}
|
{iso && <span title="ISO">{iso}</span>}
|
||||||
{focalLength && <span title="Focal length">{focalLength}</span>}
|
{focalLength && <span title="Focal length">{focalLength}</span>}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.map}>{gps && <MapExif gps={gps} />}</div>
|
<div className={styles.map}>{gps && <ExifMap gps={gps} />}</div>
|
||||||
</aside>
|
</aside>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
@ -2,22 +2,27 @@
|
|||||||
@import 'mixins';
|
@import 'mixins';
|
||||||
|
|
||||||
.exif {
|
.exif {
|
||||||
margin-top: -($spacer);
|
margin-top: -($spacer * 1.5);
|
||||||
margin-bottom: $spacer * 2;
|
margin-bottom: $spacer * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data {
|
.data {
|
||||||
|
@include breakoutviewport;
|
||||||
|
|
||||||
font-size: $font-size-mini;
|
font-size: $font-size-mini;
|
||||||
color: $brand-grey-light;
|
color: $brand-grey-light;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
margin-bottom: -3px;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
display: block;
|
display: block;
|
||||||
flex: 0 0 33%;
|
flex: 1 1 20%;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
padding: $spacer / 4;
|
padding: $spacer / 1.5;
|
||||||
|
border-bottom: 1px solid $brand-grey-dimmed;
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
@ -25,21 +30,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: $screen-sm) {
|
@media (min-width: $screen-sm) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
border-left: 1px solid $brand-grey-dimmed;
|
||||||
|
border-bottom: 0;
|
||||||
|
padding: $spacer;
|
||||||
|
|
||||||
&,
|
&,
|
||||||
&:first-child {
|
&:first-child {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
border-left: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.map {
|
.map {
|
||||||
@include breakoutviewport;
|
@include breakoutviewport;
|
||||||
|
@include media-frame;
|
||||||
|
|
||||||
border-radius: $border-radius;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: $spacer / 2;
|
|
||||||
border: 1px solid $brand-grey-dimmed;
|
|
||||||
height: 160px;
|
height: 160px;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
|
|
||||||
@mixin divider() {
|
@mixin divider() {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-bottom: 1px dashed lighten($brand-grey-light, 7%);
|
border-bottom: 1px dashed lighten($brand-grey-light, 20%);
|
||||||
margin-top: $spacer * $line-height;
|
margin-top: $spacer * $line-height;
|
||||||
margin-bottom: $spacer * $line-height;
|
margin-bottom: $spacer * $line-height;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
|
|
||||||
@mixin divider-top() {
|
@mixin divider-top() {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-top: 1px dashed lighten($brand-grey-light, 7%);
|
border-top: 1px dashed lighten($brand-grey-light, 20%);
|
||||||
margin-top: $spacer * $line-height;
|
margin-top: $spacer * $line-height;
|
||||||
margin-bottom: $spacer * $line-height;
|
margin-bottom: $spacer * $line-height;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user