Skip to content

Commit e37a7df

Browse files
authored
Merge pull request #108 from opentripplanner/alert+map-fixes
Properly render service alert body and fix retina tile display
2 parents 7a8eca2 + 56c3086 commit e37a7df

File tree

6 files changed

+36
-60
lines changed

6 files changed

+36
-60
lines changed

Diff for: example-config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ map:
3333
subdomains: 'abcd'
3434
attribution: 'Map tiles: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>'
3535
maxZoom: 20
36+
hasRetinaSupport: true
3637
- name: Stamen Toner Lite
3738
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
3839
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'

Diff for: lib/components/map/base-layers.js

-43
This file was deleted.

Diff for: lib/components/map/base-map.js

+23-15
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,33 @@ class BaseMap extends Component {
283283
{/* Create the layers control, including base map layers and any
284284
* user-controlled overlays. */}
285285
<LayersControl position='topright'>
286-
{ /* base layers */
287-
baseLayers && baseLayers.map((l, i) => (
288-
<LayersControl.BaseLayer
289-
name={l.name}
290-
checked={i === 0}
291-
key={i}>
292-
<TileLayer
293-
url={l.url}
294-
attribution={l.attribution}
295-
maxZoom={l.maxZoom}
296-
detectRetina />
297-
</LayersControl.BaseLayer>
298-
))
286+
{/* base layers */
287+
baseLayers && baseLayers.map((layer, i) => {
288+
// Fix tile size/zoom offset: https://stackoverflow.com/a/37043490/915811
289+
const retinaProps = L.Browser.retina && layer.hasRetinaSupport
290+
? { tileSize: 512, zoomOffset: -1 }
291+
: {}
292+
return (
293+
<LayersControl.BaseLayer
294+
name={layer.name}
295+
checked={i === 0}
296+
key={i}>
297+
<TileLayer
298+
url={layer.url}
299+
attribution={layer.attribution}
300+
maxZoom={layer.maxZoom}
301+
{...retinaProps}
302+
detectRetina />
303+
</LayersControl.BaseLayer>
304+
)
305+
})
299306
}
300307

301-
{ /* user-controlled overlay layers (e.g., vehicle locations, stops) */
308+
{/* user-controlled overlay layers (e.g., vehicle locations, stops) */
302309
userControlledOverlays.map((child, i) => {
303310
return (
304-
<LayersControl.Overlay key={i}
311+
<LayersControl.Overlay
312+
key={i}
305313
name={child.props.name}
306314
checked={child.props.visible}
307315
>

Diff for: lib/components/narrative/line-itin/itinerary.css

+8
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,17 @@
354354
font-size: 18px;
355355
}
356356

357+
.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-header {
358+
font-size: 14px;
359+
margin-left: 30px;
360+
font-weight: 600;
361+
}
362+
357363
.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-body {
358364
font-size: 12px;
359365
margin-left: 30px;
366+
/* white space pre-wrap is required to render line breaks correctly. */
367+
white-space: pre-wrap;
360368
}
361369

362370
.otp .line-itin .leg-body .transit-alerts .transit-alert .effective-date {

Diff for: lib/components/narrative/line-itin/transit-leg-body.js

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ class AlertsBody extends Component {
216216
return (
217217
<div key={i} className='transit-alert'>
218218
<div className='alert-icon'><i className='fa fa-exclamation-triangle' /></div>
219+
{alert.alertHeaderText
220+
? <div className='alert-header'>{alert.alertHeaderText}</div>
221+
: null
222+
}
219223
<div className='alert-body'>{alert.alertDescriptionText}</div>
220224
<div className='effective-date'>{effectiveDateString}</div>
221225
</div>

Diff for: lib/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import SwitchButton from './components/form/switch-button'
1414

1515
import LocationIcon from './components/icons/location-icon'
1616

17-
import BaseLayers from './components/map/base-layers'
1817
import BaseMap from './components/map/base-map'
1918
import DefaultMap from './components/map/default-map'
2019
import EndpointsOverlay from './components/map/endpoints-overlay'
@@ -78,7 +77,6 @@ export {
7877
SwitchButton,
7978

8079
// map components
81-
BaseLayers,
8280
BaseMap,
8381
DefaultMap,
8482
EndpointsOverlay,

0 commit comments

Comments
 (0)