我在@ agm / core库中遇到此问题。这是我的地图的样子:
有很多空格!
这是我的伴侣结构:
google-map.component.html:
<div #googleMap class=google-map></div>
google-map.component.ts:
export class GoogleMapComponent implements OnInit {
@ViewChild('googleMap',{static: true}) googleMap: ElementRef;
@Input() lat: any;
@Input() lng: any;
zoom = 15;
address: any;
marker: google.maps.Marker;
map: google.maps.Map;
geocoder: google.maps.Geocoder;
constructor(){}
ngOnInit() {
this.initMap();
}
initMap(){
const lat = parseFloat(this.lat) || 10.484676;
const lng = parseFloat(this.lng) || -66.831576;
const mapDOM = this.googleMap.nativeElement;
this.geocoder = new google.maps.Geocoder;
this.map = new google.maps.Map(mapDOM,{
center: {lat,lng},zoom: self.zoom,zoomControl: false,mapTypeControl: false,scaleControl: false,streetViewControl: false,rotateControl: false,fullscreenControl: false
});
this.marker = new google.maps.Marker({
position: {lat,map: self.map,draggable: self.markerDraggable
});
}
google-map.component.module.ts:
@NgModule({
declarations: [
GoogleMapComponent
],imports: [
Commonmodule,],exports: [
GoogleMapComponent
]
})
任何帮助将不胜感激! 谢谢