google-maps - 离子原生谷歌地图 getVisibleRegion()
问题描述
我在使用Ionic Native 和 Google Maps时遇到问题。我正在使用map.getVisibleRegion()
获取屏幕四个角的纬度。我的想法是仅加载该区域内的点,但是,在使用记录的代码后,我得到:
错误错误:未捕获(在承诺中):TypeError:无法读取 null 的属性“northeast”类型错误:无法读取 null 的属性“northeast”
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()
);
任何人都可以发光吗?
解决方案
发现问题。需要订阅GoogleMapsEvent.MAP_READY
.
推荐阅读
- sql - 从数据库中删除完全相同的重复项
- python - 为什么等高线没有出现在这个图上?
- java - 如何通过改造从 JSON 中仅获取某些字段
- matlab - Matlab中常数值和相关参数的单独定义
- python - IndentationError: unindent 不匹配任何外部缩进级别,即使我的缩进是正确的
- javascript - TypeError:无法读取未定义的属性“数据”无法正常工作
- git - 如何在 git 中更改工作分支的基本分支?
- excel - 如何在具有空值的excel中执行If条件
- node.js - 使用 PublicClientApplication、Web 或 SPA 的正确平台是什么?
- angular - Angular Form Validation How to reset textbox value