angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

agm-marker not showing

Open Len0re opened this issue 9 years ago • 5 comments

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.

Len0re avatar Oct 11 '17 19:10 Len0re

you have to place the css class at the map element

sebholstein avatar Oct 11 '17 19:10 sebholstein

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?

Len0re avatar Oct 11 '17 20:10 Len0re

Same issue

DaveBben avatar Oct 19 '17 21:10 DaveBben

Try changing css from

.agmMap {
  height: 300px;
}

to:

agm-map {
  height: 300px;
}

timhovius avatar Oct 20 '17 08:10 timhovius

You need to add css width to the agm-map element. I used the attribute directive fxFlex on mine.

samybaxy avatar Nov 07 '17 13:11 samybaxy