gpt4 book ai didi

angular - ionic 4 google-maps 5 beta "TypeError: Cannot read property ' BaseClass' of null"

转载 作者:太空狗 更新时间:2023-10-29 17:40:11 28 4
gpt4 key购买 nike

我正在尝试使用 ionic 4 google-maps@5.0.0-beta.20

我正在关注这些幻灯片:https://docs.google.com/presentation/d/1zlkmoSY4AzDJc_P4IqWLnzct41IqHyzGkLeyhlAxMDE/edit#slide=id.g282d0a7bfd_0_140

我收到此错误:“TypeError:无法读取 null 的属性‘BaseClass’”

新位置.page.html:

<ion-content>
<h3>Ionic GoogleMaps Starter</h3>
<div id="map_canvas">

</div>
</ion-content>

新位置.page.scss:

map_canvas {
height: 90%;
}

新位置.page.ts:

import { Component, OnInit } from '@angular/core';
import { Platform } from '@ionic/angular';
import { GoogleMaps, GoogleMap } from '@ionic-native/google-maps';


@Component({
selector: 'app-newlocation',
templateUrl: './newlocation.page.html',
styleUrls: ['./newlocation.page.scss'],
})
export class NewlocationPage implements OnInit {

map: GoogleMap;

constructor(private platform: Platform) { }

async ngOnInit() {
await this.platform.ready();
await this.loadMap();
}

loadMap() {
this.map = GoogleMaps.create('map_canvas');
}
}

package.json:

....
"@ionic-native/core": "5.0.0-beta.14",
"@ionic-native/google-maps": "^5.0.0-beta.20"
....
"cordova-plugin-googlemaps": {
"API_KEY_FOR_ANDROID": (API-KEY),
"PLAY_SERVICES_VERSION": "15.0.1",
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}

最佳答案

我成功了,

我只删除了'ion-content',让'div id="map_canvas"'单独存在

我的信息:

package.json:

. . .
"@ionic-native/core": "5.0.0-beta.22",
"@ionic-native/google-maps": "5.0.0-beta.22",
. . .
<plugin name="cordova-plugin-googlemaps" spec="2.4.6">
<variable name="API_KEY_FOR_ANDROID" value="(YOUR-API-KEY)" />
<variable name="PLAY_SERVICES_VERSION" value="15.0.1" />
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
</plugin>
. . .

新位置.page.html:

<div id="map_canvas"></div>

新位置.page.scss:

map_canvas {
height: 90%;
}

新位置.page.ts:

import { Component, OnInit } from '@angular/core';
import { GoogleMaps, GoogleMap } from '@ionic-native/google-maps';


@Component({
selector: 'app-newlocation',
templateUrl: './newlocation.page.html',
styleUrls: ['./newlocation.page.scss'],
})
export class NewlocationPage implements OnInit {

map: GoogleMap;

ngOnInit() {
this.loadMap();
}

loadMap() {
this.map = GoogleMaps.create('map_canvas');
}
}

新位置.module.ts

import { GoogleMaps } from '@ionic-native/google-maps/ngx';
. . .
@NgModule({
providers: [GoogleMaps],
. . .

注意:对于 web 你必须使用 'ionic cordova run browser' 而不是 'ionic serve'

关于angular - ionic 4 google-maps 5 beta "TypeError: Cannot read property ' BaseClass' of null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52161059/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com