Introduction
The AGM map hides Google places and labels using custom styles in Angular. Please follow the below steps.
Step 1
First, we have to install the following npm commands in our project.
npm install @agm/core –save
The above command adds external dependencies.
Step 2
import AgmCoreModule to your AppModule.
- import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA,ErrorHandler } from '@angular/core';
- import { BrowserModule } from '@angular/platform-browser';
- import { FormsModule } from '@angular/forms';
- import { AppComponent } from './app.component';
- import {APP_BASE_HREF} from '@angular/common';
- import { AgmCoreModule } from '@agm/core';
Add app.module.ts page with the below code to import the references for Agm Maps.
- @NgModule({
- schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA],
- imports: [BrowserModule, FormsModule,
- AgmCoreModule.forRoot({
- apiKey: 'YOUR-API-KEY'
- })
- ],
- declarations: [AppComponent],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule {}
Step 3
The app.component.ts sets latitude,longitude value and marker values as marlatitude,marongitude.
- import {
- Component
- } from '@angular/core';
- @Component({
- selector: 'my-app',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- public latitude: number = 13.0628;
- public longitude: number = 80.2517;
- public marlatitude: number = 13.0628;
- public marongitude: number = 80.2517;
- constructor() {}
- }
Step 4
In app.component.html, add the agm-map & agm-marker tag and set the height and width for map using the following code:
- <style>
- agm-map {
- height: 600px;
- width: 1200px;
- }
- </style>
- <agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="15" >
- <agm-marker [latitude]="marlatitude" [longitude]="marongitude" ></agm-marker>
- </agm-map>





Gugan RajPosted May 27, 2021, 9:21 AM
Hi bro how to refresh agm map
Maragatha ManiPosted Jan 23, 2020, 6:45 PM
Nice One...
Haridhass ManiPosted Jan 21, 2020, 11:06 AM
I have lot of learn agm map for your article
Vidyadharran GPosted Jan 17, 2020, 9:36 PM
A lot is to be learn from you bro :) thanks for sharing bro