Is there a way to set the bounds and Zoom level in AGM Map?

后端 未结 4 2091
天命终不由人
天命终不由人 2020-12-24 02:37

I am using AGM maps for my angular 4 application, there I am facing issues, I will be having the multiple markers which are fetched from api as an array of Latitude and Long

4条回答
  •  长情又很酷
    2020-12-24 03:06

    I got it to work with the LatLngBounds() function. Here is the snippet.

    import {AgmInfoWindow, MapsAPILoader} from '@agm/core';
    
    latlngBounds: any;
    
    // fits the map to the bounds
        if (this.points.length.) {
          this.mapsAPILoader.load().then(() => {
              this.latlngBounds = new window['google'].maps.LatLngBounds();
              _.each(this.points, location => {
                this.latlngBounds.extend(new window['google'].maps.LatLng(location.lat, location.lng));
              });
            }
          );
        }
    

提交回复
热议问题