【发布时间】: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