Google maps 如何在谷歌地图Api上使用LatLngBounds

Google maps 如何在谷歌地图Api上使用LatLngBounds,google-maps,zooming,markers,Google Maps,Zooming,Markers,我想根据我的标记将地图居中。 我找到了“LatLngBounds”函数来实现这一点,但在我的例子中,它不起作用 结果如下: 我们注意到缩放不够高。 我应该得到一个放大到巴黎市的结果 这是我的TS代码: 从'@angular/core'导入{Component,ViewChild,ElementRef}; 从“离子角度”导入{IonicPage,NavController}; 从“angularfire2/auth”导入{AngularFireAuth}; 从“/../../providers

我想根据我的标记将地图居中。 我找到了“LatLngBounds”函数来实现这一点,但在我的例子中,它不起作用

结果如下:

我们注意到缩放不够高。 我应该得到一个放大到巴黎市的结果

这是我的TS代码:

从'@angular/core'导入{Component,ViewChild,ElementRef};
从“离子角度”导入{IonicPage,NavController};
从“angularfire2/auth”导入{AngularFireAuth};
从“/../../providers/google-maps/google-maps”导入{GoogleMapsProvider};
声明:任何;
@IonicPage()
@组成部分({
选择器:“页面收藏夹”,
templateUrl:'favorite.html'
})
导出类收藏夹页面{
@ViewChild('map')mapRef:ElementRef;
地图:任何;
lat:字符串;
液化天然气:管柱;
查看:string=“list”;
/**
*修改器AVEC l'API
*/
收藏夹:{id_place:string,name:string,photo:string,address:string}[]=[
{“id_place”:“9054B4C53B207424DB12D23E1B34B3AE0CFE9C0”,“名称”:“巴黎马德兰咖啡馆”,“照片”:”https://lh3.googleusercontent.com/p/AF1QipMkeDY6tB5bQFEPhy1Ah4HR-2Oh7CjO_td-BbDY=s1600-w400,“地址”:“巴黎特隆切特街1号”,
{“id_place”:“cf49d5cbc84ecbe0388ef93eb80aa18f9db3ffa9”,“名称”:“Kitsune咖啡馆”,“照片”:”https://lh3.googleusercontent.com/p/AF1QipNk8GqMTGNo-QF_QwdakFaNvoGwi11tHmY-969p=s1600-w400,“地址”:“巴黎特隆切特街1号”,
{“id_place”:“b8c6ecc9f9e047dd428f3994c537c3f877ba0e30”,“名称”:“屠宰场咖啡馆”,“照片”:https://lh3.googleusercontent.com/p/AF1QipPRKYf0L3uEYzPee5Y7uUBa15Q_7WWtUTWSHvqd=s1600-w400,“地址”:“巴黎贡布斯特街10号”},
];
职位=[
[Caféparis',48.869769899999,2.3253528,1],
[Caféparis2',48.8708719,2.3317623,2],
[Caféparis 3',48.8710058,2.3249572,3]
];
私有边界=新的google.maps.LatLngBounds();
建造师(
私人aFAuth:AngularFireAuth,
公共navCtrl:NavController,
公共谷歌地图:谷歌地图提供商,
) {
}
ionViewDidLoad(){
this.initMap();
}
initMap(){
this.map=new google.maps.map(this.mapRef.nativeElement);
this.setMarkers(this.map);
this.map.fitbunds(this.bounds);
}
设置标记(地图){
对于(var i=0;i}
只是为了给大家一个建议,我确实使用了以下代码进行了缩放

      this.mapOptions = {
        center: this.latLng,
        zoom: 20, //here iam mentioned zoom level use like this
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
欲了解更多详情,请访问官方文件

例如

1:世界

5:陆地/大陆

10:城市

15:街道

20:建筑物