![](https://img-blog.csdnimg.cn/2020091222365969.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2FnYW5saWFuZw==,size_16,color_FFFFFF,t_70)
h1 {
font-size: 20px;
line-height: 30px;
};
h2 {
font-size: 14px;
line-height: 20px;
margin-bottom: 10px;
}
a {
text-decoration: none;
color: #2dc4b2;
};
#console {
position: absolute;
width: 300px;
top: 30px;
margin: 10px;
padding: 10px 20px;
background-color: white;
};
.session {
margin-bottom: 20px;
}
.row {
display: block;
height: 12px;
width: 100%;
}
.colors {
background: linear-gradient(to right, #2dc4b2, #3bb3c3, #669ec4, #8b88b6, #a2719b, #aa5e79);
margin-bottom: 5px;
}
.label {
width: 15%;
display: inline-block;
text-align: center;
}
<div id="console">
<h1>控制面板测试</h1>
<p>data from nyc</p>
<div class='session'>
<h2>Casualty</h2>
<div class='row colors'>
</div>
<div class='row labels'>
<div class='label'>0</div>
<div class='label'>1</div>
<div class='label'>2</div>
<div class='label'>3</div>
<div class='label'>4</div>
<div class='label '>5+</div>
</div>
</div>
<div class="session" id="sliderbar">
<h2>Hour: <label id='active-hour'>12PM</label></h2>
<input type="range" id="slider" class="row" min="0" max="23" step="1" value="12">
</div>
<div class='session'>
<h2>Day of the week</h2>
<div class='row' id='filters'>
<input id='all' type='radio' name='toggle' value='all' checked='checked'>
<label for='all'>All</label>
<input id='weekday' type='radio' name='toggle' value='weekday'>
<label for='weekday'>Weekday</label>
<input id='weekend' type='radio' name='toggle' value='weekend'>
<label for='weekend'>Weekend</label>
</div>
</div>
</div>
document.getElementById('slider').addEventListener('input', function(e) {
var hour = parseInt(e.target.value);
// update the map
map.setFilter('collisions', ['==', ['number', ['get', 'Hour']], hour]);
// converting 0-23 hour to AMPM format
var ampm = hour >= 12 ? '下午' : '上午';
var hour12 = hour % 12 ? hour % 12 : 12;
// update text in the UI
document.getElementById('active-hour').innerText = hour12 + ampm;
});