mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
removed console.log
This commit is contained in:
parent
d4307ae336
commit
cb02338c67
1 changed files with 9 additions and 10 deletions
|
@ -2,7 +2,11 @@ import { FC, useEffect, useCallback, memo, useState } from 'react';
|
||||||
import { OsrmRouter } from '~/utils/map/OsrmRouter';
|
import { OsrmRouter } from '~/utils/map/OsrmRouter';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectMapRoute } from '~/redux/map/selectors';
|
import { selectMapRoute } from '~/redux/map/selectors';
|
||||||
import { selectEditorRouter, selectEditorMode, selectEditorDistance } from '~/redux/editor/selectors';
|
import {
|
||||||
|
selectEditorRouter,
|
||||||
|
selectEditorMode,
|
||||||
|
selectEditorDistance,
|
||||||
|
} from '~/redux/editor/selectors';
|
||||||
import { MainMap } from '~/constants/map';
|
import { MainMap } from '~/constants/map';
|
||||||
import * as EDITOR_ACTIONS from '~/redux/editor/actions';
|
import * as EDITOR_ACTIONS from '~/redux/editor/actions';
|
||||||
import { MODES } from '~/constants/modes';
|
import { MODES } from '~/constants/modes';
|
||||||
|
@ -32,7 +36,6 @@ const RouterUnconnected: FC<Props> = memo(
|
||||||
const updateWaypoints = useCallback(
|
const updateWaypoints = useCallback(
|
||||||
({ waypoints }) => {
|
({ waypoints }) => {
|
||||||
const filtered = waypoints.filter(wp => !!wp.latLng);
|
const filtered = waypoints.filter(wp => !!wp.latLng);
|
||||||
console.log('waypoints updated: ', filtered.length);
|
|
||||||
|
|
||||||
if (filtered.length < 2) {
|
if (filtered.length < 2) {
|
||||||
setDist(0);
|
setDist(0);
|
||||||
|
@ -45,7 +48,6 @@ const RouterUnconnected: FC<Props> = memo(
|
||||||
|
|
||||||
const updateDistance = useCallback(
|
const updateDistance = useCallback(
|
||||||
({ routes, waypoints }) => {
|
({ routes, waypoints }) => {
|
||||||
console.log(routes.length, waypoints.length);
|
|
||||||
if (!routes || !routes.length || waypoints.length < 2) {
|
if (!routes || !routes.length || waypoints.length < 2) {
|
||||||
setDist(0);
|
setDist(0);
|
||||||
return;
|
return;
|
||||||
|
@ -59,15 +61,14 @@ const RouterUnconnected: FC<Props> = memo(
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalDistance = parseFloat((summary.totalDistance / 1000).toFixed(1)) || 0;
|
const totalDistance = parseFloat((summary.totalDistance / 1000).toFixed(1)) || 0;
|
||||||
const latlng = waypoints[waypoints.length - 1] && (waypoints[waypoints.length - 1].latLng) || null;
|
const latlng =
|
||||||
|
(waypoints[waypoints.length - 1] && waypoints[waypoints.length - 1].latLng) || null;
|
||||||
|
|
||||||
const angle = angleBetweenPoints(
|
const angle = angleBetweenPoints(
|
||||||
MainMap.latLngToContainerPoint(waypoints[waypoints.length - 1].latLng),
|
MainMap.latLngToContainerPoint(waypoints[waypoints.length - 1].latLng),
|
||||||
MainMap.latLngToContainerPoint(coordinates[coordinates.length - 1]),
|
MainMap.latLngToContainerPoint(coordinates[coordinates.length - 1])
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(angle);
|
|
||||||
|
|
||||||
setDist(totalDistance);
|
setDist(totalDistance);
|
||||||
setEnd(latlng);
|
setEnd(latlng);
|
||||||
setDirection(angle > -90 && angle < 90);
|
setDirection(angle > -90 && angle < 90);
|
||||||
|
@ -76,10 +77,8 @@ const RouterUnconnected: FC<Props> = memo(
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
OsrmRouter
|
OsrmRouter.on('waypointschanged', updateWaypoints)
|
||||||
.on('waypointschanged', updateWaypoints)
|
|
||||||
.on('routesfound', updateDistance)
|
.on('routesfound', updateDistance)
|
||||||
.on('routesfound', console.log)
|
|
||||||
.addTo(MainMap);
|
.addTo(MainMap);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue