google-maps - 离子原生谷歌地图如何显示中心点和非常标记
问题描述
嘿伙计们,我正在使用 Ionic Native Google Maps 插件,我正在尝试在屏幕上显示所有点以及用户位置,我可以这样做,没问题,问题是我需要用户的位置以地图为中心并显示他周围的所有点。
我一直在尝试使用 put my all points into anew LatLngBounds
并使用该方法设置每个点,.extend()
但它不起作用。
请帮忙
async expandRadius() {
const query = await this.queryPlaces(10);
get(query).then(nearByPlaces => {
const foundPlaces = [];
nearByPlaces.forEach( el => {
const placesData = {
distance: Math.floor(this.geo.point(this.centerPoint.latitude, this.centerPoint.longitude)
.distance(el.geolocation.geopoint.latitude, el.geolocation.geopoint.longitude)),
...el
};
foundPlaces.push(placesData);
// THE CENTER ISSUE STARTS HERE //
const tmp = new LatLng(el.geolocation.geopoint.latitude, el.geolocation.geopoint.longitude);
this.bounds.extend(tmp);
this.map.addMarkerSync({
position: {
lat: tmp.lat,
lng: tmp.lng
},
icon: {
url: 'www/assets/icon/pin.png',
size: {width: 23, height: 33},
}
});
});
this.map.moveCamera({
target: this.bounds.getCenter(),
tilt: 0,
});
})
.catch()
.finally( async () => await this.loading.dismiss() );
}
解决方案
推荐阅读
- spring-boot - Spring Boot Maven 插件:它实际上做了什么?
- reactjs - 在 useState 中使用对象作为状态时防止重新渲染
- android - 如何从本地存储中获取文件(pdf、jpg、docs)并创建文件
- angular - 在 Visual Studio 2019 中为 Angular 应用程序构建失败
- c# - 在 C# 的后台初始化 HalconWindow/HSmartWindowControlWPF
- verilog - 为什么在编程流光程序后LED仍然保持初始状态而模拟没有出错?
- php - FastExcel 导入附加字段数据
- java - Java中带有新行的HashMap列表到JSON字符串中
- r - 跨数据集和列匹配
- swift - 从共享表操作中快速删除应用程序