angular-google-maps
angular-google-maps copied to clipboard
agm-marker not showing
I'm trying to implement angular map on my app, but nothing seems to work.
In my html file I added the following code:
<div class="TestMap">
<agm-map [latitude]="lat" [longitude]="lng">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
</div>
On my typescript component file I added:
import { Component, OnInit } from '@angular/core';
import { AgmCoreModule } from '@agm/core';
import { AgmMap } from '@agm/core';
export class LuminaireMapMonitorComponent implements OnInit {
title: string = 'My first AGM project';
lat: number = 51.678418;
lng: number = 7.809007;
constructor() { }
ngOnInit() {
}
}
And on my css I added:
.TestMap {
height: 300px;
}
And nothing works.
you have to place the css class at the map element
It still doesn't work
I changed my html to
<agm-map class="agmMap" [latitude]="lat" [longitude]="lng">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
</agm-map>
and the css to
.agmMap {
height: 300px;
}
What am I doing wrong?
Same issue
Try changing css from
.agmMap {
height: 300px;
}
to:
agm-map {
height: 300px;
}
You need to add css width to the agm-map element. I used the attribute directive fxFlex on mine.