DrawRouteMaps icon indicating copy to clipboard operation
DrawRouteMaps copied to clipboard

Route is not Drawn on Map

Open Hamza-Rahman opened this issue 6 years ago • 9 comments
trafficstars

In My Map Two Point are ploted but path is not Shown Please Help Only Two point is visible

Hamza-Rahman avatar Feb 11 '19 06:02 Hamza-Rahman

Having same problem.

guitorioadar avatar Mar 12 '19 10:03 guitorioadar

Same issue. Please help.

devangichhatbar avatar Mar 12 '19 11:03 devangichhatbar

SOLUTION: Now you need to edit dependency to "implementation 'com.github.code2080:DrawRouteMaps:1.1.0'" and using DrawRoutMaps like this DrawRouteMaps.getInstance(getActivity(), "your_googlemap_api_key")

MAKE SURE YOU ENABLE DIRECTIONS API too.

iudragon avatar Mar 16 '19 18:03 iudragon

SOLUTION: Now you need to edit dependency to "implementation 'com.github.code2080:DrawRouteMaps:1.1.0'" and using DrawRoutMaps like this DrawRouteMaps.getInstance(getActivity(), "your_googlemap_api_key")

MAKE SURE YOU ENABLE DIRECTIONS API too.

still the route is not drawn on map

andrianm28 avatar Apr 14 '19 06:04 andrianm28

Solution: You have to add API key in the FetchUrl class and your URL should be like this:

String url = "https://maps.googleapis.com/maps/api/directions/"+output+"?"+parameters + "&key=" + MY_API_KEY

Hope you'll find your solution.

imranhsn avatar Apr 18 '19 11:04 imranhsn

Update FetchUrl class:

public class FetchUrl {
    public static String getUrl(LatLng origin, LatLng dest) {
        String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
        String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
        String sensor = "sensor=false";
        String MY_API_KEY = "";
        String parameters = str_origin + "&" + str_dest + "&" + sensor;
        String output = "json";
        return "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters + "&key=" + MY_API_KEY;
    }
}

imranhsn avatar Apr 18 '19 11:04 imranhsn

hello how do I implement Fetchurl() class? On my project I have insert the implementation dependency and DrawRouteMaps.getInstance() etc etc. Thanks

revego avatar Apr 28 '19 06:04 revego

Hi, you can solve this problem through this method:

make sure your implementation is:

implementation 'com.github.code2080:DrawRouteMaps:1.1.0'

then change the draw route to:

DrawRouteMaps.getInstance(getActivity(), "your_googlemap_api_key").draw(pos1, pos2, mMap);

Keynotes: please ensure that the API you have is enabled on google developer page you can check this on your logcat while running. Since you would need direction API to be enables and also have billing enabled.

samtamp95 avatar Sep 21 '19 08:09 samtamp95

SOLUTION: Now you need to edit dependency to "implementation 'com.github.code2080:DrawRouteMaps:1.1.0'" and using DrawRoutMaps like this DrawRouteMaps.getInstance(getActivity(), "your_googlemap_api_key")

MAKE SURE YOU ENABLE DIRECTIONS API too.

You save my Life. this corection in code: DrawRouteMaps.getInstance(ctx,api_key).draw(origin, destination, mMap);

yyaayyaatt avatar Jan 06 '20 03:01 yyaayyaatt