gpt4 book ai didi

svg - 在 Leaflet map 上显示 SVG

转载 作者:行者123 更新时间:2023-12-04 11:46:18 27 4
gpt4 key购买 nike

我有一个中等大的 SVG,可以在 Leaflet map 上显示为叠加层 - 它基本上是从道路网络中选择的道路。传单 map 实例化为:

testMap = L.map('mapdiv', { renderer: L.svg({ padding: 100 }) })
.setView([33.085, -96.815], 11);
并使用以下命令创建 SVG 层:
var imgUrl = url, imgBnds;
L.imageOverlay(imgUrl, imgBnds, {opacity:0.3}).addTo(testMap);
这一切在缩小时都能很好地显示,但是在放大时,SVG 被平铺,并且只显示左上角的平铺,即使这不是 map 中显示的区域。
SVG 具有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" x="0" y="0" width="1920" height="767"
clip-path="url(#MapClipRectangle)" style="overflow:hidden;text-rendering:optimizeLegibility" xmlns="http://www.w3.org/2000/svg">
</desc>
<defs>
<clipPath clipPathUnits="userSpaceOnUse" id="MapClipRectangle">
<rect x="0" y="0" width="1920" height="767" />
</clipPath>
<symbol id="1" style="fill:none">
<path d="M985.96 476.76 l-0.26 0.06" />
<!-- ... Many Symbols and Paths, plus some Polygons, Text, Line_artwork, Map_decoration and a Map_frame... -->
它最终看起来像这样(示例实际上显示了左上角的图块,但是如果我放大到右侧,您实际上看不到叠加层 SVG 中的任何内容):
SVG Zoom Problem
你如何阻止/控制这种行为?
Sample SVG for which this behaviour occurs

最佳答案

我没有深入研究这个问题,但为了得到一些可能有帮助的答案:
在我看来,您想将 svg 用于地理空间数据(如道路网络)似乎很不寻常。
如果将来有人遇到类似的问题,我会建议,而不是尝试修复 svg 渲染,将数据转换为 geojson,这更像是此类数据显示需求的标准选项,然后根据需要使用样式传单中的选项。
OP,你有没有找到解决方案?
请注意,我不清楚发布的图像的哪些部分是 svg 的,哪些部分是 basemap 或其他图层。

关于svg - 在 Leaflet map 上显示 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53170777/

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