mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
fixed router
This commit is contained in:
parent
42dbfb0681
commit
2be073078f
11 changed files with 241 additions and 62 deletions
|
@ -2,22 +2,8 @@ import { Map, LineUtil } from 'leaflet';
|
|||
import { ILatLng } from "~/redux/map/types";
|
||||
|
||||
export const simplify = ({ map, latlngs }: { map: Map, latlngs: ILatLng[] }): ILatLng[] => {
|
||||
const points = [];
|
||||
const target = [];
|
||||
const zoom = 12;
|
||||
const mul = 0.7; // 0 - not simplifying, 1 - very rude.
|
||||
// its better to estimate mul value by route length
|
||||
|
||||
for (let i = 0; i < latlngs.length; i += 1) {
|
||||
points.push(map.project({ lat: latlngs[i].lat, lng: latlngs[i].lng }, zoom));
|
||||
}
|
||||
|
||||
const simplified = LineUtil.simplify(points, mul);
|
||||
|
||||
// for (let i = 0; i < simplified.length; i += 1) {
|
||||
// target.push(map.unproject(simplified[i], zoom));
|
||||
// }
|
||||
//
|
||||
// return target;
|
||||
return simplified.map(item => map.unproject(item, zoom));
|
||||
const points = latlngs.map(({ lat, lng }) => map.project({ lat, lng }, zoom));
|
||||
return LineUtil.simplify(points, mul).map(item => map.unproject(item, zoom));
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue