2017-08-04 58 views
0

它的代碼低於我用來在我的頁面中顯示地圖。ionic2 - 谷歌地圖在瀏覽器中不起作用

  1. TS文件

    import { 
        GoogleMaps, 
        GoogleMap, 
        GoogleMapsEvent, 
        LatLng, 
        CameraPosition, 
        MarkerOptions, 
        Marker 
    } from '@ionic-native/google-maps'; 
    
    export class MapPage { 
    
    constructor(private googleMaps: GoogleMaps){} 
    
        ngAfterViewInit() { 
        this.loadMap(); 
        } 
    
        loadMap() { 
        let element: HTMLElement = document.getElementById('map'); 
        let map: GoogleMap = this.googleMaps.create(element); 
        map.one(GoogleMapsEvent.MAP_READY).then(() => { 
          console.log('Map is ready!'); 
        }); 
        } 
    } 
    
  2. HTML代碼塊

    <div #map id="map" style="height:100%;"></div> 
    
+0

爲什麼它不起作用?請添加有關錯誤的所有相關信息,否則我們將無法幫助您:( – sebaferreras

+0

在控制檯中沒有錯誤,只出現空白屏幕 –

回答

1

由於您使用Google Maps從離子本土,它不會在瀏覽器中運行。 Ionic Native/Cordova plugins只能在模擬器/真實設備上工作只有

+1

謝謝,問題已解決,如果somthing後來出現,我會尋求你的幫助 –

+0

很高興聽到:)當然,如果你需要幫助,可以隨意編輯問題或創建一個新問題。 – sebaferreras

相關問題