简体   繁体   中英

Use method from angular-google-maps agmCircle into typescript file

I want to get the bounds of a circle when it is changed. From here https://angular-maps.com/api-docs/agm-core/directives/AgmCircle.html I can see it has a "getBounds" method, how can I access it from my typescript file to log this data? Currently my html circle component looks like this:

<agm-circle [latitude]="lat + 0.3" [longitude]="lng" 
      [radius]="10000"
      [fillColor]="'blue'"
      [circleDraggable]="true"
      [editable]="true"
      (dragEnd)="test($event)"
      >
  </agm-circle>

And I expect to have a function like this:

test(m){
   // get bounds from circle in some way
}

Just add it as a ViewChild in your component

@ViewChild(AgmCircle) child;

test(m) {
    console.log(this.child.getBounds())
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM