javascript - Vue Leaflet 更改缩放控件的样式
问题描述
我正在尝试使用 Vue 在暗模式下制作地图应用程序,但由于某种原因,我无法更改缩放控件的样式。目前我正在尝试以下
template>
<div class="main-map">
<l-map :zoom="zoom" :center="currLatLng" :options="{zoomControl: false}">
<l-tile-layer :url="url" :attribution="attribution"></l-tile-layer>
<l-control-zoom position="topleft" :options="{class: 'leaflet-control-zoom'}"></l-control-zoom>
</l-map>
</div>
</template>
<script>
import {LMap, LTileLayer, LCircleMarker, LControlZoom} from 'vue2-leaflet'
export default {
name: 'Map',
components: { LMap, LTileLayer, LCircleMarker, LControlZoom },
props: ['currLatLng', 'trackpoints', 'collectedPoints'],
data() {
return {
zoom:15,
url:'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png',
attribution:'© <a href="https://stadiamaps.com/">Stadia Maps</a>, © <a href="https://openmaptiles.org/">OpenMapTiles</a> © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'
}
}
<style scoped>
.leaflet-control-zoom a {
color: white !important;
background: rgba(0, 0, 0, 0.5) !important;
transition: all 0.5s ease;
}
.leaflet-control-zoom a:hover {
color: white !important;
background: rgba(0, 0, 0, 0.9) !important;
}
</style>
但缩放控制看起来仍然正常。
我尝试了同样的方法,:options="{class: 'leaflet-control-zoom'}"
其中也没有任何作用。我在这里想念什么?
解决方案
我遇到了同样的问题。
我试了一下,换成:options="{zoomControl: false}"
了<l-map>
,:options="{zoomControl: true}"
效果很好。
推荐阅读
- json - postgres jsonb根据不同的数组元素更新数组元素
- amazon-web-services - CDK 中的高级权限处理:passRole、创建实例和传递多个权限
- reactjs - @testing-library/与 msw/node 反应;window.fetch 未在 POST 上返回正文
- android - 在现有框架上升级 Appium(驱动程序异常)
- python - 用另一列替换数据框值的一列
- c - 如何通过输入字符“q”终止while循环
- java - 如何在 Intellij 中添加或更新 tomcat 服务器的上下文根
- java - 当 Java 中的引用为空时,我有什么替代“instanceof”的方法?
- c# - 向量上的乘法矩阵
- javascript - 使用 TypeScript 和 Webpack 的可选链接失败的传播