Skip to content

Commit

Permalink
Merge pull request #108 from opentripplanner/alert+map-fixes
Browse files Browse the repository at this point in the history
Properly render service alert body and fix retina tile display
  • Loading branch information
landonreed authored Sep 11, 2019
2 parents 7a8eca2 + 56c3086 commit e37a7df
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 60 deletions.
1 change: 1 addition & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ map:
subdomains: 'abcd'
attribution: 'Map tiles: &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>'
maxZoom: 20
hasRetinaSupport: true
- name: Stamen Toner Lite
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
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>.'
Expand Down
43 changes: 0 additions & 43 deletions lib/components/map/base-layers.js

This file was deleted.

38 changes: 23 additions & 15 deletions lib/components/map/base-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,25 +283,33 @@ class BaseMap extends Component {
{/* Create the layers control, including base map layers and any
* user-controlled overlays. */}
<LayersControl position='topright'>
{ /* base layers */
baseLayers && baseLayers.map((l, i) => (
<LayersControl.BaseLayer
name={l.name}
checked={i === 0}
key={i}>
<TileLayer
url={l.url}
attribution={l.attribution}
maxZoom={l.maxZoom}
detectRetina />
</LayersControl.BaseLayer>
))
{/* base layers */
baseLayers && baseLayers.map((layer, i) => {
// Fix tile size/zoom offset: https://stackoverflow.com/a/37043490/915811
const retinaProps = L.Browser.retina && layer.hasRetinaSupport
? { tileSize: 512, zoomOffset: -1 }
: {}
return (
<LayersControl.BaseLayer
name={layer.name}
checked={i === 0}
key={i}>
<TileLayer
url={layer.url}
attribution={layer.attribution}
maxZoom={layer.maxZoom}
{...retinaProps}
detectRetina />
</LayersControl.BaseLayer>
)
})
}

{ /* user-controlled overlay layers (e.g., vehicle locations, stops) */
{/* user-controlled overlay layers (e.g., vehicle locations, stops) */
userControlledOverlays.map((child, i) => {
return (
<LayersControl.Overlay key={i}
<LayersControl.Overlay
key={i}
name={child.props.name}
checked={child.props.visible}
>
Expand Down
8 changes: 8 additions & 0 deletions lib/components/narrative/line-itin/itinerary.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,17 @@
font-size: 18px;
}

.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-header {
font-size: 14px;
margin-left: 30px;
font-weight: 600;
}

.otp .line-itin .leg-body .transit-alerts .transit-alert .alert-body {
font-size: 12px;
margin-left: 30px;
/* white space pre-wrap is required to render line breaks correctly. */
white-space: pre-wrap;
}

.otp .line-itin .leg-body .transit-alerts .transit-alert .effective-date {
Expand Down
4 changes: 4 additions & 0 deletions lib/components/narrative/line-itin/transit-leg-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ class AlertsBody extends Component {
return (
<div key={i} className='transit-alert'>
<div className='alert-icon'><i className='fa fa-exclamation-triangle' /></div>
{alert.alertHeaderText
? <div className='alert-header'>{alert.alertHeaderText}</div>
: null
}
<div className='alert-body'>{alert.alertDescriptionText}</div>
<div className='effective-date'>{effectiveDateString}</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import SwitchButton from './components/form/switch-button'

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

import BaseLayers from './components/map/base-layers'
import BaseMap from './components/map/base-map'
import DefaultMap from './components/map/default-map'
import EndpointsOverlay from './components/map/endpoints-overlay'
Expand Down Expand Up @@ -78,7 +77,6 @@ export {
SwitchButton,

// map components
BaseLayers,
BaseMap,
DefaultMap,
EndpointsOverlay,
Expand Down

0 comments on commit e37a7df

Please sign in to comment.