TypeError:无法读取未定义的属性“ getDiv”

时间:2019-07-23 17:56:52

标签: google-maps ionic-framework

白天好。

我需要在WebView应用程序中插入一个地图组件。代码与官方文档中的示例完全相同。

  loadMap() {
    let self=this;
    this.showLoading('Loading map').then(()=>{

      console.log('Setting env vars...');

    Environment.setEnv({
        'API_KEY_FOR_BROWSER_RELEASE': _here_was_key_,
        'API_KEY_FOR_BROWSER_DEBUG': _here_was_same_key_
    });

    let mapOptions: GoogleMapOptions = {
      camera: {
         target: {
           lat: 59.939095,
           lng: 30.315868
         },
         zoom: 18,
         tilt: 30
       }
    }; // presence of this doesn't matter

    console.log('Creating map...');

    // Create a map after the view is ready and the native platform is ready.
    this.map = GoogleMaps.create('map_canvas',mapOptions); // last param doesn't matter
    console.log('Map created.',this.map);

    // Wait the maps plugin is ready until the MAP_READY event
    /* // all code below (markers, their handlers, camera) is commented during debug
    */
    self.loading.dismiss();
    });
  }
<div [ngStyle]="{'display':(howToChoosePickPoint=='map')?'block':'none'}">
  <ras-map></ras-map>
</div>

“ ras-map”标签包含组件代码:

<div id="map_canvas">
        <button ion-button small (click)="zoomOut()">-</button><button ion-button small (click)="zoomIn()">+</button>
</div>

主div标签内部或外部的按钮位置无关紧要。

它在框架更新之前就可以使用了,但是现在在创建GoogleMap对象后几秒钟(控制台日志中的“ Map created。GoogleMap {_objectInstance:Map}”行)之后,现在在控制台中看到一条错误消息:“ ERROR TypeError :无法读取未定义的属性“ getDiv”     在CordovaGoogleMaps .__ remove ...”。地图(和任何HTML元素都属于Google)完全不会显示。

0 个答案:

没有答案