How to call HERE Maps API v3 using HTTPS

我怕爱的太早我们不能终老 提交于 2019-11-30 20:23:12
HERE Developer Support

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

For the HTTPS:

  • load the js and css files via "relative protocol"
  • force the HTTPS while you are creating the instance of H.service.Platform

For the "relative protocol", load the CSS in head section:

<link rel="stylesheet" type="text/css" href="//js.api.here.com/v3/3.0/mapsjs-ui.css" />

for the "relative protocol", load the JS before closing the BODY tag:

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

With these steps all js and CSS are loaded correctly. But you will have some problem when the SDK will load Tiles. To allow to the SDK to load correctly all assets needed in HTTPS protocol you need to use 'useHTTPS' options in the Platform constructor:

this.platform = new H.service.Platform({
  'app_id': process.env.VUE_APP_HERE_APP_ID,
  'app_code': process.env.VUE_APP_HERE_APP_CODE,
  'useHTTPS': true
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!