【问题标题】:Ionic Native Google Maps getVisibleRegion()离子原生谷歌地图 getVisibleRegion()
【发布时间】:2019-12-14 12:59:17
【问题描述】:

我在使用 Ionic Native 和 Google 地图时遇到问题。我正在使用map.getVisibleRegion() 来获取屏幕四个角的latLng。我的想法是只加载该区域内的点,但是,在使用记录的代码后,我得到:

ERROR 错误:未捕获(承诺中):TypeError:无法读取 null 的属性“northeast” TypeError: Cannot read property ‘northeast’ of null

this.map.getMyLocation()
      .then(
        (location: MyLocation) => {
          this.map.animateCamera({
            target: location.latLng,
            zoom: 17,
            tilt: 0,
            bearing: 150
          });
          // Getting the visible region of the map
          const visibleRegion = this.map.getVisibleRegion();
          this.map.addPolygonSync({
            'points': [
              visibleRegion.northeast,
              {lat: visibleRegion.northeast.lat, lng: visibleRegion.southwest.lng},
              visibleRegion.southwest,
              {lat: visibleRegion.southwest.lat, lng: visibleRegion.northeast.lng}
            ],
            'strokeColor' : 'blue',
            'strokeWidth': 2,
            'fillColor': 'rgba(255,0,0,.5)'
          });
        },
        this.loading.dismiss()
      );

任何人都可以发光吗?

【问题讨论】:

    标签: google-maps ionic-framework ionic4 ionic-native


    【解决方案1】:

    发现问题。需要订阅GoogleMapsEvent.MAP_READY

    【讨论】:

      猜你喜欢
      • 2018-05-24
      • 2018-04-29
      • 2016-07-05
      • 2018-06-01
      • 2018-04-14
      • 2019-07-15
      • 2013-09-10
      • 1970-01-01
      • 2018-11-15
      相关资源
      最近更新 更多