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

Transferring an array to PHP using AJAX

In this coding scenario, I initialize my array: let myArray = []; Within a loop, elements are added to the array as follows: myArray.push($(this).data('id')); // Example: [1, 2, 3, 4] Subsequently, I transmit this data to PHP using AJAX throu ...

Enable strict mode for older web browsers

I would like to incorporate the "use strict"; statement into my function, but unfortunately it is not compatible with older browsers such as ie7 and ie8. Is there a workaround to ensure this functionality works in legacy browsers? Could someone please cla ...

"Embed" three.js within SmartMS

Is it possible to incorporate this simple three.js example into Smart Mobile Studio without extensive wrapping? I attempted to copy the window.onload content into an asm section but was unsuccessful. <!DOCTYPE html> <html> <head> <t ...

Utilizing AngularJS's $http.get to fetch video IDs and then combining them with the /embed endpoint through the ng

Currently, I am utilizing $http.get to retrieve a list of videos from YouTube using the API endpoint 'MY_API_KEY'. The goal is to construct a link with the video ID in the format: "{{videoID}}". However, extracting the videoID proves to be chall ...

Refreshing Child's Activities

In my scenario, I am displaying data in a child action and utilizing buttons to modify the displayed information. Here is an example of how I am achieving this: Index.cshtml <head> <script type="text/javascript"> $("#RefreshView").on ...

Leveraging Async/Await to track error counts across three distinct loops, each invoking an asynchronous function in every iteration

While I have experience with Callbacks, Async/Await and Promises are new concepts to me. In my node.JS server project, I am faced with the challenge of counting errors generated by thousands of asynchronous calls from three different async functions. My g ...

Emptying the data of a form that has been submitted using Ajax

None of the similar questions really address the issue from my perspective. I am facing a challenge with a user registration form where I utilize .post for ajax handling. Below is the code snippet: $('#register_user_form').submit(function(){ ...

Based on the action taken, send specific data through AJAX - whether a form submission or a div click

There is a function called search, which can be triggered either by clicking on a div or submitting a form. When the div is clicked, the id of the div is sent as data in an AJAX call. However, if the form is submitted, I want to send the inputted data thr ...

Incorporate a new CSS class into a DIV using JavaScript

Sample HTML: <div id="bar" class="style_one"></div> Is there a way to include the class style_two without deleting style_one? final outcome: <div id="bar" class="style_one style_two"></div> ...

Unable to retrieve information from the database during the http.get request

Hey everyone, I've encountered an issue that I need help with. I'm working on retrieving data from a database using an HTTP call and then returning it to the front end. Here's what I have so far: app.get('/contentHandler/post/frontPage ...

Handling responses from http requests in Node.js

Below is the code snippet I am working with: exports.post = function(request, response) { var httpRequest = require('request'); var uri = "url.."; httpRequest(uri, function(err, responseHeaders, bodyResponse) { var data = JSON.parse( ...

Refresh the navigation bar on vuejs post-login

Creating a client login using Vue has been a challenge for me. My main component includes the navigation bar and the content rendering component. The navigation component checks if the user is logged in to display the buttons for guests and hide the button ...

Having trouble getting my angular form validation to function properly

Even though I disabled Bootstrap's validation while using Angular, the validation for every input field still doesn't work. It seems like I have everything set up correctly. My code looks like this below with no success on input validation: < ...

Determine whether a response is not received within 8 seconds

One of the methods in my Angular component is responsible for returning data Here is a snippet of that method getRecognitionById() { this.loaderService.show(null, true); forkJoin( this.vendorWebApiService.getRecognitionById(this.executiveCh ...

Organize an array of objects in JavaScript into a structure with nested children

I am facing a challenge with organizing an array of objects based on parentId and sort values. I need to create a nested array with 'children' and ensure proper sorting. Consider the following data: [{ id: 1, sort: 2, parentId: null ...

What is the process for converting strings or text to EBCDIC using JavaScript?

In the midst of developing a website, I am working on a feature that allows users to input a minimum of 256 characters/strings (with code verification), choose between ASCII or EBCDIC conversion, and view the converted text string displayed on the page bas ...

Techniques for verifying phone numbers from various countries

The number of digits in a mobile number differs from country to country. I have tried using regular expressions, however, for example, India allows 10 digits, but this does not validate UAE, where the number of digits can range from 7 to 9. ...

The function Jquery .stop does not exist

I am encountering an issue with the magicline.stop function while attempting to implement an underline sliding effect for my navbar. I have tried to troubleshoot the problem but have been unsuccessful so far. Below is the code snippet: <nav class=" ...

Issues with border/padding and overlay in Packery Grid Layout

After spending some time working on a grid layout using the metafizzy isotope packery mode, I have encountered a few issues. To illustrate my problem, I have provided a link to a codepen below: http://codepen.io/anon/pen/EgKdpL Although I am satisfied wi ...

Unable to retrieve AJAX response

I've been working on a page where I'm using AJAX to fetch data based on the selection of radio buttons. The three options available are 'Unapproved', 'Approved' and 'All'. My goal is to display the corresponding user ...