<?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 Tarang Sachdev on Medium]]></title>
        <description><![CDATA[Stories by Tarang Sachdev on Medium]]></description>
        <link>https://medium.com/@tarangsachdev?source=rss-4b9195e1044b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Cn31O92P9sbZltP5IY11yA.jpeg</url>
            <title>Stories by Tarang Sachdev on Medium</title>
            <link>https://medium.com/@tarangsachdev?source=rss-4b9195e1044b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:35:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tarangsachdev/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[Google Maps DirectionsRenderer with ReactJs]]></title>
            <link>https://medium.com/@tarangsachdev/google-maps-directionsrenderer-with-reactjs-8074a4d0173e?source=rss-4b9195e1044b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8074a4d0173e</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google-maps]]></category>
            <dc:creator><![CDATA[Tarang Sachdev]]></dc:creator>
            <pubDate>Thu, 13 Sep 2018 09:16:42 GMT</pubDate>
            <atom:updated>2018-09-13T09:54:50.452Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I want to share how to use DirectionsRenderer for google maps using reactJs(version 16.5.0).</p><p>I have created an application using the <a href="https://github.com/facebook/create-react-app">create-react-app</a> command.</p><pre>create-react-app react-google-maps-demo<br>cd react-google-maps-demo</pre><p>You have App.js.</p><pre>import React, { Component } from “react”;<br>class App extends Component {<br>render() {<br> // return &lt;div&gt;App.js&lt;/div&gt;;<br>}<br>}<br>export default App;</pre><p>I used an npm library for react-maps ‘<a href="https://www.npmjs.com/package/google-maps-react">google-maps-react</a>’.</p><pre>npm install react-google-maps --save</pre><p>Run an application to test if application display on http://localhost:3000/.</p><pre>npm run start</pre><p>now, create a file called <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionsIndex.js"><strong>DirectionsIndex.js</strong></a><strong> </strong>under src/components/Directions and add content from <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionsIndex.js">here</a>.</p><p>now create a file called <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponent.js"><strong>DirectionRenderComponent.js</strong></a><strong> </strong>under src/components/Directions and add content from <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponent.js">here</a>.</p><p>create <a href="https://github.com/tarangJs/react-google-maps-demo/tree/master/src/utility"><strong>utility</strong></a> folder under the src folder.please check this <a href="https://github.com/tarangJs/react-google-maps-demo/tree/master/src/utility"><strong>Utility</strong></a><strong>.</strong></p><p>you need to change the api key in /utility/constants.js file.</p><pre>const key = “your_key”; <br>export const G_API_URL = `https://maps.googleapis.com/maps/api/js?key=${key}&amp;&amp;v=3.exp&amp;libraries=geometry,drawing,places`;</pre><p>That’s it. You can now able to see maps with routes on application.</p><p>I have added one file called <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponentPromise.js"><strong>DirectionRenderComponentPromise.js</strong></a> (click <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponentPromise.js">here</a> to go to that file),which is nothing but async Version of <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponent.js"><strong>DirectionRenderComponent.js</strong></a><strong>.</strong>(click <a href="https://github.com/tarangJs/react-google-maps-demo/blob/master/src/components/Directions/DirectionRenderComponent.js">here</a> to go to that file).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Kd2Wqg15LAFELiTNLAofwg.jpeg" /><figcaption>Draw path between two location</figcaption></figure><p>I have changed current-location based on way-points, which I got when first request made. One can also change implementation by getting current location from server(websocket,api,mqqt etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*-vTISm7g6g7sWTWcTsESfw.png" /><figcaption>if current location change it will again draw path between those two location including current-location.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8074a4d0173e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>