Он показывает черный экран при попытке загрузить карту на устройстве с Ionic 2 Google Map Native PluginIOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Он показывает черный экран при попытке загрузить карту на устройстве с Ionic 2 Google Map Native Plugin

Сообщение Anonymous »



note этот проект должен быть запускаться на устройстве, ios или andriod



/>
Я установил нативный плагин Google Maps в свой проект Ionic 2, используя команду

Код: Выделить всё

$ ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"
, как показано в следующей ссылке: http://ionicframework.com/docs/v2/native/google-maps/

Тогда я бы запустил команду $ Ionic Platform Add IOS
, а затем $ yonic build IOS

$ wome as way is as way is as way yos

$. /> Когда я пытаюсь отобразить карту, я вижу черный экран, не знаю, что отсутствует!

Код: Выделить всё

import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { HomePage } from '../pages/home/home';

@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
/src/app/app.component.ts

Код: Выделить всё

import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen } from 'ionic-native';

import { HomePage } from '../pages/home/home';

import {
GoogleMap,
GoogleMapsEvent,
GoogleMapsLatLng,
CameraPosition,
GoogleMapsMarkerOptions,
GoogleMapsMarker
// GoogleMapsMapTypeId
} from 'ionic-native';

@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage = HomePage;

constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
Splashscreen.hide();

let map = new MapPage();
map.loadMap();
});
}
}

class MapPage {
constructor() {}

// Load map only after view is initialize
ngAfterViewInit() {
this.loadMap();
}

loadMap() {
// make sure to create following structure in your view.html file
// and add a height (for example 100%) to it, else the map won't be visible
// 
//
// 

// create a new map by passing HTMLElement
let element: HTMLElement = document.getElementById('map');

let map = new GoogleMap(element);

// create LatLng object
let ionic: GoogleMapsLatLng = new GoogleMapsLatLng(43.0741904,-89.3809802);

// create CameraPosition
let position: CameraPosition = {
target: ionic,
zoom: 18,
tilt: 30
};

// listen to MAP_READY event
map.one(GoogleMapsEvent.MAP_READY).then(() => {
// move the map's camera to position
map.moveCamera(position); // works on iOS and Android
});

// create new marker
let markerOptions: GoogleMapsMarkerOptions = {
position: ionic,
title: 'Ionic'
};

map.addMarker(markerOptions)
.then((marker: GoogleMapsMarker) => {
marker.showInfoWindow();
});
}
}
/src/pages/home/home.htmlобразно


Ionic Blank







< /code>

может кто -нибудь, пожалуйста, помочь решить проблему. Ваша помощь очень ценится.>

Подробнее здесь: https://stackoverflow.com/questions/427 ... google-map
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «IOS»