Tips & Tricks: Automatically generate code snippets using the HERE Maps API Explorer

30 October 2015 by Portal Admin

You probably know that you can use the HERE REST API Explorer to help you create and test your REST API calls. You probably also know that the API Explorer has several neat features, like the ability to view and set parameters such as latitude and longitude on an interactive map. For example, if you want to calculate a route, you can simply click on the waypoint0 parameter in the explorer and then drag the reticle to your desired starting location. The correct latitude and longitude will then automatically be generated for that parameter.

Clicking on a waypoint parameter allows you to select the location on a map

What you may not know however, is that you can also use the API Explorer to automatically generate cURL commands, code snippets in jQuery and code snippets for our Maps API for JavaScript. This useful feature is hiding behind the "View Code" button in the upper right corner. Click this button and you will get three options to generate your code: "as cURL command", "as jQuery code snippet" and "as Maps API for JavaScript code snippet".

Select the View Code button to generate code snippets

The results will show up on the page right above the Response area. For example, if you wanted to calculate a route from the Fernsehturm to the Kurfürstendamm in Berlin using public transport, the API Explorer would generate the following cURL command using the "View Code" feature.

If you're using jQuery, it can also generate the following jQuery code snippet.

Finally, the code snippet for the HERE Maps API for JavaScript would look like this:

Remember that you need to replace {YOUR_APP_CODE} and {YOUR_APP_ID} with your own code and ID for all of these examples. You can get these by signing up for your free trial at developer.here.com .




top 

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.