Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ components:
setOrigin: Set Origin
MainMobile:
invalidScreen: Invalid mobile screen
Mapillary:
altText: Imagery of the street
MobileOptions:
header: Set Search Options
ModeDropdown:
Expand Down
2 changes: 1 addition & 1 deletion lib/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class Map extends Component {
{showDiagram && <LegDiagram leg={diagramLeg} />}
{showMapillary && (
<MapillaryFrame
id={activeMapillaryImage}
onClose={() => setMapillaryId(null)}
url={activeMapillaryImage}
/>
)}
</div>
Expand Down
35 changes: 22 additions & 13 deletions lib/components/map/mapillary-frame.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { Button } from 'react-bootstrap'
// eslint-disable-next-line sort-imports-es6-autofix/sort-imports-es6
import { useIntl } from 'react-intl'
import React, { useEffect, useState } from 'react'

// eslint-disable-next-line sort-imports-es6-autofix/sort-imports-es6
import Icon from '../util/icon'

const MapillaryFrame = ({
id,
onClose
onClose,
url
}: {
id: string
onClose?: () => void
url: string
}): React.ReactElement => {
const intl = useIntl()
const [fakeLoad, setFakeLoad] = useState(false)
useEffect(() => {
// If the ID changed, show a "fake" loading screen to indicate to the user
// something is happening
setFakeLoad(true)
setTimeout(() => setFakeLoad(false), 750)
}, [id])
setTimeout(() => setFakeLoad(false), 500)
}, [url])

return (
<div className="leg-diagram" style={{ height: '50vh', zIndex: 999 }}>
Expand All @@ -31,16 +33,23 @@ const MapillaryFrame = ({
>
<Icon className="fa-spin" type="spinner" />
</div>
<iframe
frameBorder="0"
src={`https://www.mapillary.com/embed?image_key=${id}&style=photo`}
<div
style={{
display: fakeLoad ? 'none' : 'block',
alignItems: 'center',
display: 'flex',
height: '100%',
width: '100%'
justifyContent: 'center'
}}
title="Imagery of the street"
/>
>
<img
alt={intl.formatMessage({ id: 'components.Mapillary.altText' })}
src={`${url}`}
style={{
height: '100%',
visibility: fakeLoad ? 'hidden' : 'visible'
}}
/>
</div>
<Button
aria-label="Close"
className="mapillary-close-button close-button clear-button-formatting"
Expand Down