Skip to content

Draw a route on the map #537

Open
Open
@daniimd

Description

@daniimd

I would like to know if it is possible to draw a route on the map similar to the image below:

1_n7RewtYOFB9bt8PF9qcF3w

I didn't find anything from this library saying anything about it, if anyone can help me please.

My code:


import React, { useRef, useState, useCallback } from 'react';
import { Map, GoogleApiWrapper, Marker, Polygon, Listing, Polyline, MapWithADirectionsRenderer } from 'google-maps-react';

export const Geo = ({ google }) => {
  const mapRef = useRef(null);

  return (
    <>
      <Map 
          ref={mapRef}
		  google={google}
		  containerStyle={{
            height: '100vh',
            width: '100%',
          }}
          initialCenter={{
              lat: -23.49111858736318,
              lng: -46.711258044347865
           }}
           zoom={17}
	  >
          <Marker name={'Your position'}/>
      </Map>
    </>
  );
};

export default GoogleApiWrapper({
  apiKey: "key", // google maps key
})(Geo);

Activity

owenherbert

owenherbert commented on Mar 28, 2024

@owenherbert

Hey did you ever find if this was possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @daniimd@owenherbert

        Issue actions

          Draw a route on the map · Issue #537 · fullstackreact/google-maps-react