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

后端 未结 4 2084
天命终不由人
天命终不由人 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:17

    @renil-babu

    Instead of doing the fitBounds on mapReady, you have to do it in your adding markers subscription block

          const bounds: LatLngBounds = new google.maps.LatLngBounds();
          for (const mm of this.markers) {
            bounds.extend(new google.maps.LatLng(mm.lat, mm.lng));
          }
          // @ts-ignore
          this.agmMap._mapsWrapper.fitBounds(bounds);
    

提交回复
热议问题