Domanda

There exist some parameters in the HERE Advanced Routing REST API which is not available in the Javascript API. Is it possible to combine the two APIs somehow (ie. request json route from REST API and display it in the Javascript map?)

È stato utile?

Soluzione

The JavaScript API just maps the REST API up in a nice package but there is nothing unique about it. You should be able to call any of the REST API functions with jQuery using $.ajax. Looking at the API explorer I see that they use query parameters for most things so you will want to use the data attribute for all the params.

$.ajax({
  url: "http://image.maps.cit.api.here.com/mapview/1.6/route",
  type: "GET",
  data: {
    app_id: "xxxxx", 
    app_code: "xxxxx",
    r0: "52.5338,13.2966,52.538361,13.325329"
    r1: "52.540867,13.262444"
    ...
  },
  success: function () {...}
  error: function () {...}
});

Altri suggerimenti

I actually ended up implementing this a bit differently, but I think both ways work equally well. The important part that gave me grief was the &routeattributes=all. Without it, shapes aren't returned so you can't draw the polyline, etc. In the PDF doc it's referred to as responseattributes in a few places which really messed me up. Anyways, I did:

var url = "https://route.st.nlp.nokia.com/routing/6.2/calculateroute.json?
app_id=XXX&app_code=XXX&routeattributes=all&jsoncallback=myCallBackFunction
&jsonattributes=41&waypoint0=[...]";

and then:

var script = document.createElement('script');
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);

and

var myCallBackFunction = function (data) { ... }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top