Home:ALL Converter>Angular google maps api for angular project

Angular google maps api for angular project

Ask Time:2018-03-27T00:24:21         Author:Anil

Json Formatter

I have integrated angular google maps in my project and able to display map by referring to the following tutorial, https://angular-maps.com/guides/getting-started/,

Here we are trying to add agm-map in HTML and load the map,

I want to get the agm-map object in my .ts file.

How can we get that? Tried all possibilities like adding an id attribute to the agm-map tag, but did not work for me.

Suggest me any new ideas. Thanks for the help in advance.

Author:Anil,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49496209/angular-google-maps-api-for-angular-project
psychotiq :

Just import it from @agm/core using import { AgmMap } from '@agm/core';.\n\nYou can then use it like any other object.\n\nimport { Component, ElementRef } from '@angular/core';\nimport { AgmMap, GoogleMapsAPIWrapper } from '@agm/core';\n\n@Component({\n selector: 'app-root',\n templateUrl: 'app.component.html',\n styleUrls: ['app.component.css'],\n})\nexport class AppComponent {\n title: string = 'My first AGM project';\n lat: number = 51.678418;\n lng: number = 7.809007;\n // declaration\n map: AgmMap;\n\n // ElementRef and GoogleMapsAPIWrapper are params in\n // AgmMap's constructor.\n constructor (el: ElementRef, api: GoogleMapsAPIWrapper) {\n // init\n this.map = new AgmMap(el, api);\n // example properties, there are lots more\n this.map.backgroundColor = 'red';\n this.map.scrollwheel = true;\n this.map.draggable = true;\n }\n}\n\n\nSee the API docs for AgmMap here.\n\nEDIT : In response to \"adding height to AgmMap.\"\n\nAdd a height for the agm-map element in the corresponding app.component.css file.\n\nagm-map {\n height: 300px;\n}\n",
2018-03-26T16:51:14
Ritu Shikha :

npm install --save @types/googlemaps\n\ndeclare const google: any;",
2018-12-31T10:00:14
yy