在heremaps js api中获取错误“这不是有效的app_id和app_code对”

时间:2017-03-16 09:32:38

标签: here-api

我收到错误“这不是有效的app_id和app_code对”,但凭据是正确的。我检查了app_id和app_code之间没有交换的值以及HERE提供的值。

Project是在两天前创建的,所以我认为应用凭据已列入白名单。

更新 这是我的代码,我只是按照快速入门教程

platform: any = new H.service.Platform({
 'app_id': '{myId}',
 'app_code': '{myCode}'
});
defaultLayers: any = this.platform.createDefaultLayers();

ngAfterContentInit() {
 this.map = new H.Map(
   document.getElementById('mapContainer'),
   this.defaultLayers.normal.map,
   {
     zoom: 10,
     center: { lat: 52.5, lng: 13.4 }
   });
}

在创建地图期间我遇到了错误

1 个答案:

答案 0 :(得分:0)

首先,请检查app_id和app_code是否正确。如果未给出app_code,则生成app_key,如果正确,则添加以下行useHTTPS:true。下面给出的代码将生成一个非交互式的here映射。 提到的其中一项使用该行的评论(useHTTPS:true)对我有用。请参阅-HERE Maps Javascript API

here-map.component.html

<div #map style="width: 100 vw; height: 100vh"></div>

here-map.component.ts


declare var H:any;
@Component({
  selector: 'app-here-map1',
  templateUrl: './here-map1.component.html',
  styleUrls: ['./here-map1.component.css']
})
export class HereMap1Component implements OnInit {

  private platform : any;
  private map: any;

  @ViewChild("map")
  private mapElement : ElementRef;
  constructor() { }

  ngOnInit() {
    this.platform = new H.service.Platform({
      "app_id": "30AGFBeGk5SbuC4ODTt3E",
      "app_code": "1o21ou0xtPdf7NmvVtoD3Vvke1L0Z0eX56TU5R_FrJg",
      useHTTPS: true
    })
  }

  ngAfterViewInit(){
    this.map = new H.Map(
      this.mapElement.nativeElement,
      this.platform.createDefaultLayers().normal.map,
      {
        zoom : 10,
        center : { lat : 37, lng: -121}
      }
    )
  }

}

我已经参考了youtube视频中的代码-https://www.youtube.com/watch?v=30TNa6LZmFk

相关问题