如何解决有没有办法在反应传单中添加“对齐道路”?
我正在寻找使每个标记之间的所有多段线“对齐道路”的方法,而不是在 a 点和 b 点之间绘制一条直线。因此,在任何两点之间,我希望这些点自动放置在最近的道路上(如果标记未放置在道路上),并希望沿两点之间最短的道路路线生成折线。我刚刚开始研究 google maps API,看起来他们有这个功能,但我不想改变我已经拥有的一切。这是我的代码。
import React from "react";
import { useSelector,useDispatch } from "react-redux";
import { MapContainer,TileLayer,Polyline } from "react-leaflet";
import "../styles/Map.css";
import AddMarkers from "./AddMarkers";
const Map = () => {
const markers = useSelector((state) => state.markers);
return (
<div className="leaflet-container">
<MapContainer
center={[50.868031999999996,-9]}
zoom={20}
scrollWheelZoom={true}
>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<AddMarkers />
{markers.length > 1 && (
<Polyline
positions={markers.map((marker) => {
return [marker.lat,marker.lng];
})}
/>
)}
</MapContainer>
</div>
);
};
export default Map;
解决方法
看来您可能会搜索:https://github.com/makinacorpus/Leaflet.Snap
这应该可以将可拖动标记捕捉到折线和其他图层。
此页面中的 Demo-Link 已损坏,但在 GitHub-Page 中似乎有详细说明,如何使用。我认为您需要使用 let
Source = Excel.CurrentWorkbook(){[Name="Table10"]}[Content],//Group by Name and Other Data
// extract a delimited list of the sub_text and sub_codes
#"Grouped Rows" = Table.Group(Source,{"name","other_data"},{
{"sub_text",each Text.Combine([sub_text],";"),type text},{"sub_code",each Text.Combine([sub_code],type text}
}),//split the delimited lists into separate columns.
#"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows","sub_text",Splitter.SplitTextByDelimiter(";",QuoteStyle.Csv)),#"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter","sub_code",QuoteStyle.Csv))
in
#"Split Column by Delimiter1"
部分进行实施。
祝您好运,让您的地图按预期工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。