Create multiple paths by extracting endpoints from an array and plotting them on HERE maps

I am currently in the process of developing a web application that needs to generate a large number of routes and display their distances. The starting waypoint remains constant for all routes. My approach to achieving this is as follows:

function calculateRouteFromAtoB (platform, end) {
    var router = platform.getRoutingService(),
        routeRequestParams = {
            mode: 'fastest;truck;traffic:enabled',
            height: '7',
            weightPerAxle: '4',
            trailersCount: '1',
            routeattributes : 'sh,bb,gr',
            dirtRoad: '-3',
            tollroad:'-3',
            //tunnelCategory: 'E',
            //maneuverattributes: 'direction,action',
            'waypoint0': '50.6431675,29.9479832', 
            'waypoint1': end  
        };

    router.calculateRoute(
        routeRequestParams,
        onSuccess,
        onError
    );
}

var tt;
for(tt=0;tt<array_with_endpoints.length;tt++){
    calculateRouteFromAtoB(platform,array_with_endpoints[tt]);
}

The calculateRouteFromAtoB function adds the route to the map along with its distance on the panel. However, there seems to be an issue as the displayed route length on the panel does not accurately represent the real route length. It appears that endpoints are being randomly chosen. If you have any suggestions on how to modify the code so that it selects endpoints in order, please share your insights.

Answer №1

Have you considered exploring matrix routing for your project? Check out this resource for more information!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating with React Router Dom and parsing objects in search parameters

Currently, I am utilizing React Router Dom v6 and require the ability to retain object search parameters within the URL. My current approach involves: const [searchParams, setSearchParams] = useSearchParams(); const allSearchParams = useMemo(() => { ...

The onChange Event triggers only once in a checkbox input

I am implementing a checkbox component that emits an event to the parent component. However, in the parent component, I am facing an issue where I need to perform different actions based on whether the checkbox is checked or not, but it seems to only work ...

Implementing pagination in Firestore using React-Redux

I'm currently working on implementing pagination with Firebase and React Redux Toolkit. I've grasped the logic behind it, but I'm facing challenges when integrating it with Redux. Initially, my approach was to store the last document in the ...

Utilizing computed properties to implement table filtering in Vue.js

I am currently working on a table generated from an array of objects in VuE.js and struggling with implementing computed properties for filtering. I need help figuring out the correct way to use filter() within my computed properties to filter the table ba ...

How can I append an object key to the end of a URL link within an anchor tag

I seem to be facing a problem where I am attempting to append the key of my object at the end of a URL. It appears to work fine as a button, but for some reason the key is not being displayed within the href attribute. Typically, I would use "+" to conca ...

I am having trouble getting text to display properly in a jQuery Mobile dialog

I am attempting to dynamically set the header and button texts using JavaScript, but unfortunately it's not working as expected. To demonstrate the issue, I have added my code on jsfiddle: http://jsfiddle.net/tMKD3/8/. Here is the HTML code: <bod ...

Ways to determine the total number of pages in a PDF using a stream

Utilizing a library such as pdf-parse enables us to extract the number of pages (numpages) from a PDF buffer. The challenge I am facing is handling large buffers that cannot be stored in memory, prompting me to consider streaming it instead: const response ...

Transferring HTML variables to an Angular Component

I am currently trying to transfer the information inputted into a text-box field on my webpage to variables within the component file. These variables will then be utilized in the service file, which includes a function connected to the POST request I exec ...

Is it possible to upload a file to my web application without having configured any backend system?

Currently, I am in the process of developing a landing page that includes a form where users can input their data and send an email. I have successfully implemented the form using HTML, CSS, and JavaScript, and I have even managed to incorporate the email- ...

I have implemented the Angular "Date" filter, but I'm unsure about the meaning of this numerical value

The Angular tutorial showcases the date filter with the following example: {{ 1304375948024 | date }} --> May 2, 2011` How would you notate the expression 1304375948024? ...

Using jQuery to set the background-image on the body's after pseudo-element with CSS

I am currently utilizing body:after for setting the page wallpaper. body:after { background-image: url('assets/img/wallpapers/<?php echo $getWallpaperFile; ?>'); } CSS content: ' '; display: block; position: absolute; left: ...

Collaborate and pass around SQL connections among different modules

One of my recently developed modules consists of three main functions: Establishing a SQL connection Executing a query Closing the connection This module is called in script.js along with other custom modules responsible for various operations that requi ...

Using the ngrx signalStore within the facade design pattern - a step-by-step guide

How can I utilize ngrx's new signalStore in Angular to fetch locations of arms, save them in the state, and replace a service with LOCATION_STORE after setting the locations on a map with markers? The challenge lies in waiting for the response of loca ...

Can a fixed position element disregard its parent?

I've been experimenting with a div that switches between position: absolute and position:fixed on scroll. You can view the issue with my code on JSFiddle: http://jsfiddle.net/g9NVj/2/ The problem areas are the pink and blue boxes that change color as ...

Javascript behavior during execution can vary from what is observed during debugging

I'm currently facing an issue while trying to debug a script. Everything seems to work fine in debug mode, but not during runtime. Here's the JavaScript function causing trouble: function Add() { ... $('#Value').val($('#V ...

developing a dynamic map with javascript

In the image provided, my concept is for it to initially be without a green tint. However, when the user hovers over specific areas, they would turn green and become clickable links. There are multiple areas in the image, with this being just one example. ...

Encountering an Error with "Access-Control-Allow-Origin" Request While Trying to Access the API

I'm currently facing an issue with fetching data from the Rescue Time API. My request is made in a JavaScript file using the jQuery get() method. Below is the snippet of JavaScript code related to the API GET request: $.get('https://www.rescueti ...

By utilizing the HTML element ID to retrieve the input value, it is possible that the object in Typescript may be null

When coding a login feature with next.js, I encountered an issue: import type { NextPage } from 'next' import Head from 'next/head' import styles from '../styles/Home.module.css' import Router from 'nex ...

Advanced Layout: Angular Event window:scroll not Triggering

One issue I am facing is that the event gets triggered on some components but not others. For example, it fires as soon as I route to all other components except for the Landing component. Below are my code snippets: <-- Main Component --> <div c ...

Is there a way to automatically transfer the store's order value to my payment gateway's checkout process during the checkout process?

I am facing an issue with integrating the Razorpay payment gateway into my online store built on ecwid. The process involves decrypting order details from the store, sending them to the payment gateway for processing, and redirecting the customer back to t ...