tiaanduplessis / react-native-google-maps-directions

🚕 Get direction using Google Maps in React Native 🚗
MIT License
182 stars 28 forks source link

encodeURIComponent was messing the url #28

Closed bilaltirmizi123 closed 2 years ago

bilaltirmizi123 commented 4 years ago

The function encodeURIComponent was messing up the final url due to which the map was returning an invalid response. Removing the encodeURI component function call fixed it for me.

Test Case:

handleGetDirections = () => {
    const data = {
       source: {
        latitude:Number(24.9158528),
        longitude:Number(67.1313890)
      },
      destination: {
        latitude: Number(24.9158528),
        longitude: Number(67.1313892)
      },
      params: [
        {
          key: "travelmode",
          value: "driving"        // may be "walking", "bicycling" or "transit" as well
        },
        {
          key: "dir_action",
          value: "navigate"       // this instantly initializes navigation using the given travel mode
        }
      ],
      waypoints: [

        {
          latitude: Number(-33.8600026),
          longitude: Number(18.697453)
        },
           {
          latitude: Number(-33.8600036),
          longitude: Number(18.697493)
        }
      ]
    }

    getDirections(data)
  }
tiaanduplessis commented 2 years ago

Thanks for the PR. This should however be resolved with #31