distanceTo Leaflet Routing Machine show error not a function

17 views Asked by At
                let destination = L.latLng(lat, lng);
                var dataSavepoint = points.filter((point) => {
                    return point.options.jenis === 'savepoint';
                });
                // Create a graph to represent the map
                var graph = {};
                graph[myLocation._latlng] = {};
                dataSavepoint.forEach((data) => {
                    graph[data._latlng] = {};
                });
                for (let location1 in graph) {
                    for (let location2 in graph) {
                        if (location1 !== location2) {
                            graph[location1,location2] = location1.distanceTo(location2);
                        }
                    }
                }

i want to get distance for every location1 and location2, but it show error in distanceTo is not a function? anyone can help?

i want to get distance of location1 and location2 from graph;

0

There are 0 answers