嗨,我正在尝试在我的离子应用程序中使用 HERE 地图。我关注了这个博客 https://developer.here.com/blog/display-an-interactive-here-map-in-an-ionic-framework-application
我已经创建了 HERE 帐户并从那里获取 javascrio APPID 和 APIKEY 并在我的代码中使用,就像这样..
主页.ts
import { Component, ViewChild, ElementRef } from '@angular/core';
declare var H: any;
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
@ViewChild("map", {static: false})
public mapElement: ElementRef;
public constructor() { }
public ngOnInit() { }
public ngAfterViewInit() {
let platform = new H.service.Platform({
"app_id": 'XXXXXXX',
"app_code": 'XXXXXXX'
});
let defaultLayers = platform.createDefaultLayers();
let map = new H.Map(
this.mapElement.nativeElement,
defaultLayers.normal.map,
{
zoom: 10,
center: { lat: '22.258651999999998', lng: '71.1923805' }
}
);
let behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
}
}
我的主页.html
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Blank
</ion-title>
</ion-toolbar>
</ion-header>
<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Blank</ion-title>
</ion-toolbar>
</ion-header>
<div id="container">
<div #map style="width: 100%; height: 100%"></div>
</div>
</ion-content>
但是当我在浏览器上运行项目时出现错误..