gpt4 book ai didi

css - Leaflet Draw spritesheet图标问题 - 丢失然后未对齐

转载 作者:太空狗 更新时间:2023-10-29 12:31:00 33 4
gpt4 key购买 nike

我在我的一个元素中加入了传单绘制。我的问题是图标没有显示在工具栏中。它看起来像这样:

enter image description here

环顾四周我发现THIS发布并按照说明进行操作。我在 Leaflet Draw 文件夹中找到了 spritesheet 并像 htis 一样链接到它:

    .leaflet-draw-toolbar a {
background-image: url('E:/MappingProject/Leaflet.Draw/src/images/spritesheet.png');
background-repeat: no-repeat;
}

我最终得到了这个:

enter image description here

我似乎无法找到任何其他解决方案来使此 spritesheet 在框中对齐。它看起来不是拉出单个图标,而是将整个工作表放在每个按钮中。

这是我实例化 L.FeatureGroup() 和 L.Control.Draw() 的代码:

    function logIn(){
map = L.map('map').setView([51.505, -0.09], 13);
OpenStreetMap_HOT.addTo(map);
$("#logInScreen").css('display', 'none');
addSideBars();
addDrawToMap();
}

/////////////////////////////////////////////
//DRAW FUNCTIONALITY
///////////////////////////////////////////
function addDrawToMap(){
map.addControl(drawControl);
map.addLayer(drawnItems);
}
var drawnItems = new L.FeatureGroup();
var drawControl = new L.Control.Draw({
position: 'topright',
draw: {
polyline: true,
polygon: true,
circle: true,
marker: true
},
edit: {
featureGroup: drawnItems,
remove: true
}
});

谁有这方面的经验?

最佳答案

您很可能错过了 Leaflet-draw CSS file .

正是在该文件中定义了 .leaflet-draw-toolbar a 等 CSS 规则。

示例没有此文件,但有您的 CSS 规则:

var map = L.map('map').setView([48.86, 2.35], 11);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var drawControl = new L.Control.Draw({
position: 'topright'
});
map.addControl(drawControl);
.leaflet-draw-toolbar a {
background-image: url('https://unpkg.com/leaflet-draw@1.0.2/dist/images/spritesheet.png');
background-repeat: no-repeat;
color: transparent !important;
}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet-src.js" integrity="sha512-IkGU/uDhB9u9F8k+2OsA6XXoowIhOuQL1NTgNZHY1nkURnqEGlDZq3GsfmdJdKFe1k1zOc6YU2K7qY+hF9AodA==" crossorigin=""></script>
<script src="https://unpkg.com/leaflet-draw@1.0.2/dist/leaflet.draw-src.js"></script>

<div id="map" style="height: 200px"></div>

此文件的示例:

var map = L.map('map').setView([48.86, 2.35], 11);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var drawControl = new L.Control.Draw({
position: 'topright'
});
map.addControl(drawControl);
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet-src.js" integrity="sha512-IkGU/uDhB9u9F8k+2OsA6XXoowIhOuQL1NTgNZHY1nkURnqEGlDZq3GsfmdJdKFe1k1zOc6YU2K7qY+hF9AodA==" crossorigin=""></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet-draw@1.0.2/dist/leaflet.draw-src.css" />
<script src="https://unpkg.com/leaflet-draw@1.0.2/dist/leaflet.draw-src.js"></script>

<div id="map" style="height: 200px"></div>

关于css - Leaflet Draw spritesheet图标问题 - 丢失然后未对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48572987/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com