ionic-team / ionic-native-google-maps

Google maps plugin for Ionic Native
Other
221 stars 125 forks source link

KMLファイルが読み込めない(then catch どちらも通過しない)(Can not read KML file) #67

Closed chankane closed 6 years ago

chankane commented 6 years ago

I'm submitting a ... (check one with "x")

OS: (check one with "x")

cordova information: (run $> cordova plugin list)

cordova-plugin-device 2.0.2 "Device"
cordova-plugin-googlemaps 2.4.2 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.2 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.1.0 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"

If you use @ionic-native/google-maps, please tell the package.json (only @ionic-native/core and @ionic-native/google-maps are fine mostly)

"@ionic-native/core": "^4.12.1",
"@ionic-native/google-maps": "^4.12.0",

Current behavior:

fail

Expected behavior:

success --->

Related code, data or error log (please format your code or data):

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {
  GoogleMaps,
  GoogleMap,
  Marker,
  LatLng,
  GoogleMapsMapTypeId,
  KmlOverlay,
} from '@ionic-native/google-maps';

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

  // readonly is const(final)
  readonly CENTER: LatLng = new LatLng( 35.549415, 139.779842 );
  map: GoogleMap;
  myMarker: Marker;
  osaka: Marker;

  constructor( public navCtrl: NavController ) {
   this.createMap();
   this.readKml();
  }

  createMap(){
    // create a map
    this.map = GoogleMaps.create('map_canvas', {
      mapType: GoogleMapsMapTypeId.SATELLITE,
      camera: {
        target: this.CENTER,
        zoom: 5
      }
    });

    // create a marker
    this.myMarker = this.map.addMarkerSync({
      title: 'Haneda Airport',
      animation: 'BOUNCE',
      position: this.CENTER
    });
  }

  readKml() {
    //alert('before');
    alert('success');
    this.map.addKmlOverlay( {
      url: 'assets/kml/test.kml'
    } ).then( ( kmlOverlay :KmlOverlay ) => {
      alert('success');
    } ).catch( (err: any) => alert('Error :_(') );
    //alert('after');

    // create a marker (Osaka Airport)
    /*this.myMarker = this.map.addMarkerSync({
      title: 'Osaka Airport',
      animation: 'BOUNCE',
      position: new LatLng( 34.789580, 135.438089 ),
      icon: 'skyblue'
    });*/
  }
}
    this.map.addKmlOverlay( {
      url: 'assets/kml/test.kml'
    } ).then( ( kmlOverlay :KmlOverlay ) => {
      alert('success');
    } ).catch( (err: any) => alert('Error :_(') );

この部分が問題です. アラートが表示されないのはなぜでしょうか? [ Why 'then' and 'catch' are not working? ] ちなみに @ionic-native/core@ionic-native/google-maps をベータ版にアップグレードした場合はそもそも地図が表示されませんでした.(タイトルすら) 今回のケースの git を公開いたします.[ My git repository is here ] ionic-googlemaps-test.git

wf9a5m75 commented 6 years ago

こっちと同じなので、ここのスレッドはクローズします。

Due to multi post with another thread, I close this thread.