What are some tips for increasing your points on the journey using Here Maps?

While plotting a route, I noticed that the segments on highways are quite far apart. Is there a way to get a more detailed routing with finer points along the journey?

$.ajax({
      url: 'https://route.cit.api.here.com/routing/7.2/calculateroute.json',
      type: 'GET', dataType: 'jsonp', jsonp: 'jsoncallback',
      data: {
        waypoint0: '59.159486,17.645687',
        waypoint1: "59.397635,17.891626",
        mode: 'fastest;car;traffic:enabled',
        app_id: 'VXZP5fwHfh2WQIWnp0Zx',
        app_code: 'NgKq-kVEUMKxxNpBKP_hBg',
        departure: 'now'
      },
      success: function (data) {
        moves = data.response.route[0].leg[0].maneuver;
        timeAvailable = 45;
        trackPoints = moves.map(function (d) { return { 
          lat: d.position.latitude, 
          lng: d.position.longitude,
          time = d.travelTime }; });

        for (var i = 0; i < trackPoints.length; i++) {
          smackUpArea(map, trackPoints[i], timeAvailable);
          timeAvailable -= trackPoints[i].time;
        };
      }
    })
    

Ideally, I would like to have a point marked every x kilometers or y minutes driven. Is this level of detail achievable in the routing system?

Answer №1

If you're looking for more detailed routing information, you can include the links that make up the route. Just add the legattributes query parameter with a value of links or li. This will provide a link array for each leg object within the route. Additionally, you have the flexibility to choose which details you want to see for each link, using the linkattributes query parameter. This could include attributes such as length, shape, remaining time, or distance along the route when reaching that specific link. For more options, refer to the RouteLinkAttributeType section.

In your code, this concept can be applied as shown below:

  data: {
    waypoint0: '59.159486,17.645687',
    waypoint1: "59.397635,17.891626",
    mode: 'fastest;car;traffic:enabled',
    app_id: 'VXZP5fwHfh2WQIWnp0Zx',
    app_code: 'NgKq-kVEUMKxxNpBKP_hBg',
    departure: 'now',
    legattributes: 'li',
    linkattributes: 'le,rt'
  },

An example of a returned link in the response would look something like this:

{
  "linkId":"-733185668",
  "shape":["52.5158286,13.3774424","52.5158286,13.3774424"],
  "length":0,
  "remainTime":249,
  "speedLimit":13.8888893,
  "_type":"PrivateTransportLinkType"
}

Answer №2

One potential approach could involve introducing shape as a parameter in the route attributes of the request. By extracting every two pairs of lat/long from the response and calculating routes between them, the segment can be broken down into smaller pieces. While not ideal, this method diverges from the initial question's parameters. The process of using time-based or distance-based isoline with the start as the center to determine intersections may seem challenging. It is hoped that a more efficient solution can be found by another individual.

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

Filter the array while maintaining its current structure

I'm struggling to create an array filter that can handle exact and partial data within a nested array structure. The challenge is maintaining the integrity of the top-level structure while filtering based on data in the second layer. Here's an ex ...

What is the best way to locate a div element with a specific style?

What is the method to locate a div element by its style? Upon inspecting the source code in IE6, here is what I find: ...an><div id="lga" style="height:231px;margin-top:-22px"><img alt="Google"... How can this be achieved using JavaScript? ...

When a Vue.js datepicker is set as required, it can be submitted even if

When using the vuejs-datepicker, setting the html required attribute on input fields may not work as expected. This can lead to the form being submitted without an input value. <form> <datepicker placeholder="Select Date" required></datep ...

Retrieve the variance between two arrays and store the additions in AddedList and the removals in RemovedList using typescript

I am still getting the hang of Typescript and I am trying to figure out the best solution for my issue. I have two arrays, A and B, and I need to identify the difference between them in relation to array A. The goal is to separate the elements that were ad ...

Retrieving text content from multiple classes with a single click event

There are numerous elements each having class names p1, p2, p3,...p14. Consequently, when attempting to extract text from the clicked class, text from all classes is retrieved! For instance, if the expected text is 80, it ends up being 808080080808080808 ...

Add a container element resembling a div inside a table without implementing the table layout

I am working with a table that is rendered by DataTable, and I have the requirement to dynamically append new elements inside the table like this: The dark grey area represents the new DOM elements that need to be inserted dynamically. The first row cont ...

Using jQuery to restrict the occurrence of Ajax POST requests to once every 10 seconds

I created an interactive wizard using HTML that displays multiple panels. Users can navigate through the panels using a Next button and there is also a Finish button available. Whenever the user clicks on the next button, I have set up a click handler to s ...

Creating an HTML table from an array in an email using PHP

How can I use data collected by Javascript to generate an email in PHP? The array structure in JavaScript is like this: Menu[ item(name,price,multiplier[],ingred), item(name,price,multiplier[],ingred) ] The array Menu[] is dynamically cr ...

"Filtering a JSON File Based on Button Data Attributes: A Step-by-

I am working with a set of buttons that have specific data-map attributes as shown below: <button class="btn btn-default mapper" data-map="2015-11-13">Monday</button> <button class="btn btn-default mapper" data-map="2015-11-14">Tuesday&l ...

I am experiencing an issue with my date filter where it does not display any results when I choose the same date for the start and end dates. Can anyone help me troub

Having an issue with my custom filter pipe in Angular. When I select the same dates in the start and end date, it doesn't display the result even though the record exists for that date. I've noticed that I have to enter a date 1 day before or ea ...

Instructions on how to include a conditional click attribute to a hyperlink

Is there a way to make an anchor tag trigger a function only if a specific variable is set? In this scenario, the variable name is assigned the value of "Shnick", so when the link is clicked it should activate the func() method. However, clicking the link ...

How can the border of the select element be removed when it is active in select2

After examining the CSS code, I am still unable to locate the specific property that is being applied to the main element. I am currently customizing the select2 library to suit my needs. However, I am stuck in the CSS as I cannot determine which property ...

Trouble with X-editable linking to database for updates

Utilizing the X-Editable plugin within my PHP application to update fields in a table and utilizing a POST file to update the database. Below is the form code: <table id="restaurant" class="table table-bordered table-striped"> <tbody> ...

No error reported upon trying to render json output

I'm having an issue where the following code is not displaying any output. Can someone help me identify what mistake I might be making? This is the HTML file: <head> <script type = "text/javascript"> function ajax_get_json() { var h ...

How can VueJS cycle through the arrays within an object?

Is there a way to efficiently iterate through arrays within an object like in this example? I have a simple code snippet that currently outputs indexes in order, but I'm looking to access the values of the array instead. <template> <div&g ...

Tips for transmitting an onChange function from a parent component to a child component in material UI

As a newcomer to react and material UI, I am currently working on developing a dropdown select component. My goal is to pass onChange functions to the component from its parent. Despite following the official documentation closely, I've encountered an ...

What is the best approach to transforming my jQuery function into CSS to ensure responsiveness?

I have created a jQuery animation with four functions named ani1(), ani2(), ani3(), and ani4(). Everything is working fine on desktop, but now I am facing the challenge of making it responsive for mobile devices. I am looking for CSS code to replicate the ...

Parsing URLs with Node.js

Currently, I am attempting to parse the URL within a Node.js environment. However, I am encountering issues with receiving null values from the following code. While the path value is being received successfully, the host and protocol values are returnin ...

ViewContainerRef fails to render component on the DOM

@Component({ selector: 'my-cmp', template: ` <div #target></div> ` }) export class MyCmp { @ViewChild('target', {read: ViewContainerRef}) target : ViewContainerRef; render() { let component = createComponent(met ...

Issues arise when attempting to transfer strings through ajax to a Node.js server that is utilizing express.js

On my website, I am encountering a problem where certain characters are being lost when I send strings to my Node.js server. // Client: microAjax("/foo?test="+encodeURI("this is ++ a test"), function callback(){}); // Server: app.get('/foo',fun ...