agm zoom to marker
<agm-map [zoom]="13" [latitude]="127.1" [longitude]="141.1">
<agm-marker [latitude]="127.1" [longitude]="141.1"></agm-marker>
</agm-map>
agm zoom to marker
<agm-map [zoom]="13" [latitude]="127.1" [longitude]="141.1">
<agm-marker [latitude]="127.1" [longitude]="141.1"></agm-marker>
</agm-map>
zoom map around the marker angular
import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
import { MyMarker } from './marker';
import { MarkersService } from './markers.service';
import { GoogleMapsAPIWrapper, AgmMap, LatLngBounds, LatLngBoundsLiteral} from '@agm/core';
declare var google: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, AfterViewInit {
title = 'AGM project (so48865595)';
lat = 41.399115;
lng = 2.160962;
markers: MyMarker[];
@ViewChild('AgmMap') agmMap: AgmMap;
constructor(private markersService: MarkersService) { }
ngOnInit() {
this.getMarkers();
}
ngAfterViewInit() {
console.log(this.agmMap);
this.agmMap.mapReady.subscribe(map => {
const bounds: LatLngBounds = new google.maps.LatLngBounds();
for (const mm of this.markers) {
bounds.extend(new google.maps.LatLng(mm.lat, mm.lng));
}
map.fitBounds(bounds);
});
}
getMarkers(): void {
this.markers = this.markersService.getMarkers();
}
mapIdle() {
console.log('idle');
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us