<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lalaji Sananjaya on Medium]]></title>
        <description><![CDATA[Stories by Lalaji Sananjaya on Medium]]></description>
        <link>https://medium.com/@lala.sananjaya?source=rss-9406d51f8b72------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YjTM1Mk8UaE3J869.jpg</url>
            <title>Stories by Lalaji Sananjaya on Medium</title>
            <link>https://medium.com/@lala.sananjaya?source=rss-9406d51f8b72------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:58:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lala.sananjaya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Adding Google Maps to Angular 2+]]></title>
            <link>https://medium.com/@lala.sananjaya/adding-google-maps-to-angular-2-f5f15c3a28e7?source=rss-9406d51f8b72------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5f15c3a28e7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular-maps-integration]]></category>
            <category><![CDATA[angular-map]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-google-map]]></category>
            <dc:creator><![CDATA[Lalaji Sananjaya]]></dc:creator>
            <pubDate>Tue, 04 Jun 2019 15:40:01 GMT</pubDate>
            <atom:updated>2019-06-04T15:40:01.910Z</atom:updated>
            <content:encoded><![CDATA[<p>Angular Google Maps (short name: AGM).</p><p><em>Integrating AGM module with your project.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*fP_Q4FOjEXnUc-iHApH9Ew.png" /></figure><p>First things first, we will need a Google Maps API key. Get it from the following link if you haven’t got one.</p><p><a href="https://developers.google.com/maps/documentation/javascript/get-api-key">Use API Keys | Maps JavaScript API | Google for Developers</a></p><p>Run the following command to add it to your project via the Node Package Manager (NPM).</p><blockquote>npm install @agm/core — save</blockquote><h3>Setup @NgModule</h3><p>Open src/app/app.module.ts and import the AgmCoreModule</p><pre><strong>import</strong> { AgmCoreModule } <strong>from</strong> &#39;@agm/core&#39;; </pre><pre><strong>@NgModule</strong>({   <br>   imports: [<br>     BrowserModule,<br>     CommonModule,<br>     FormsModule,<br>     AgmCoreModule.forRoot({<br>       apiKey: &#39;<em>YOUR_KEY</em>&#39;<br>     })<br>   ],<br>   providers: [],<br>   declarations: [ AppComponent ],<br>   bootstrap: [ AppComponent ] })</pre><pre> <strong>export</strong> <strong>class</strong> AppModule {}</pre><h3>Setup app component</h3><p>Open the file src/app/app.component.ts and add the variables like below:</p><pre>   title: string = &#39;My first AGM project&#39;;<br>   lat: number = 51.678418;<br>   lng: number = 7.809007;</pre><h3>Setup the template</h3><p>Open the file src/app/app.component.html and add the following content:</p><pre> &lt;h1&gt;{{ title }}&lt;/h1&gt;<br><em><br></em> &lt;agm-map [latitude]=&quot;lat&quot; [longitude]=&quot;lng&quot;&gt;<br>   &lt;agm-marker [latitude]=&quot;lat&quot; [longitude]=&quot;lng&quot;&gt;&lt;/agm-marker&gt;   <br> &lt;/agm-map&gt;</pre><p>This creates a google map on the page with the given lat/lng from <em>the component as the initial center of the map and set a marker.</em></p><p>Change them as you wish in the src/app/app.component.ts to change the initial point.</p><h3>Setup the CSS file</h3><p>For the map to be visible, a height should be provided. Add the code following code in the style-sheet.</p><pre><strong>agm-map</strong> {<br>   height: 300px;<br>}</pre><p><em>It is really important that you define a height component `agm-map`. Otherwise, you won’t see a map on the page!</em></p><p>So we have created all the needed source files, so everything should be ready to build an run the application.</p><p>Now save All the files and run the following command in the <strong>project root folder</strong>:</p><pre>ng serve --open</pre><p>This will compile the project and automatically open the Web-app in the browser. Else you can open the following URL in your browser:</p><pre><a href="http://localhost:4200/">http://localhost:4200/</a></pre><h3>Adding an Info Window to a Map Marker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*0UnQno1kKodoRhl9BcDVTg.png" /></figure><p>Easy..</p><p>By making a &lt;agm-info-window&gt; a child element of an &lt;agm-marker&gt;, AGM will automatically make sure that clicking the marker will open the info window.</p><p>Example:</p><pre>&lt;agm-map [latitude]=&quot;lat&quot; [longitude]=&quot;lng&quot; &gt;<br>   &lt;agm-marker [latitude]=&quot;lat&quot; [longitude]=&quot;lng&quot;&gt;         <br>     &lt;agm-info-window&gt;<em>InfoWindow content</em>&lt;/agm-info-window&gt;<br>   &lt;/agm-marker&gt;<br>&lt;/agm-map&gt;</pre><p>You can save all the files and visit the browser to check the update.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5f15c3a28e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>