地图不会在iOS设备中显示

时间:2017-10-01 18:28:16

标签: angular google-maps ionic-framework native

在Android工作但在iOS设备中,没有任何反应。 我尝试将调用loadMap的块代码放在ionViewDidLoad,ngOnInit和ngAfterViewInit方法中,但是没有任何反应

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

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
})

export class HomePage {
    map: GoogleMap;
    mapElement: HTMLElement;

    constructor ( platform: Platform, private googleMaps: GoogleMaps ) {
        platform.ready().then(() => {
            try {
                this.loadMap();
            } catch ( e ) {
                console.error(e);
            }
        })
    }

    loadMap () {
        this.mapElement = document.getElementById('map');

        let mapOptions: GoogleMapOptions = {
            camera: {
                target: {
                    lat: 43.0741904,
                    lng: -89.3809802
                },
                zoom: 18,
                tilt: 80
            }
        };

        //this.map = new GoogleMap(this.mapElement, mapOptions);
        this.map = this.googleMaps.create('map', mapOptions);
    }
}

0 个答案:

没有答案
相关问题