Search code examples
javascriptgrailshere-api

How to call HERE Maps API v3 using HTTPS


How can I call HERE maps through HTTPS ?

I'm using HTTPS on my server so when I call this:

    <script src="http://js.api.here.com/v3/3.0/mapsjs-core.js" type="text/javascript" charset="utf-8"></script>
    <script src="http://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"></script>

The browser blocks the request because of "Mixed Content" and therefore no map is shown...

I tried to change "http" to "https" on the script source but I get the same issue cause both javascripts have "http" calls inside their codes.

By the way the backend is written in Grails and the channel is secured using Spring Security Core plugin.


Solution

  • You need to load the API from https and additionally you need to set:

    // Create a platform object to communicate with the HERE REST APIs
    var platform = new H.service.Platform({
        useCIT: true,
        app_id: app_id,
        app_code: app_code,
        useHTTPS: true
    });
    

    The Trick is useHTTPS: true, as in described in the Documentation at: HERE Developers Guide