当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Free SDK for Turn-by-turn navigation

问题描述:

I'm looking for a free SDK that gives turn-by-turn navigation to integrate in a mobile application. Does anynone knows one? I needed one to work with android or has a javascript api so I could use with PhoneGap or Titanium.

Thanks in advance.

网友答案:

MapQuest has a good set of free services and SDKs that are available. They include directions and many other navigation functions.

From what I have seen and tried they are the best out there that place no restrictions on your use in application or on the web.

Check them out here

Update (based on Comment):

There are several out there and it depends on what you are trying to do that will make one better than the other. Some of the best ones are Google and Bind, but I think they both have restrictions on how you use them (in a free usage scenario and I don't know what you are willing to do). I will not link to those, they are easy enough to find.

I have looked at OpenRouteService but I like MapQuest. Programmable web has many listed and do a pretty good job keeping up with what is out there. If you look in the mapping category you will find several services that will probably fit your needs.

You might want to pull different parts from different providers. Google is a great one stop shop if you can stay within their restrictions.

Good luck!

网友答案:

Mapbox has an SKD for android: https://www.mapbox.com/blog/mapbox-android/

The is also Mapbox on Titanium project https://github.com/adampax/titanium-mapbox which, at the time of writing this, is maintained and growing.

Another option would be Skobbler/Telenav which also have a Android SDK:

http://developer.skobbler.com/features#mobileDevicesAndWeb

which can be downloaded from here

I know they also have a javascript library, but I'm not sure if that would work/how it would work with Titanium or PhoneGap. (let me know in a comment if you find out :) )

网友答案:

A very old question, but it might help someone. Mapbox has recently introduced a new directions library for android which provides turn by turn navigation. It is free.

Using the directions library is pretty straightforward. Just add the following to your build.gradle to start using it

repositories {
  mavenCentral()
}

dependencies {
    compile ('com.mapbox.mapboxsdk:mapbox-android-directions:[email protected]'){
        transitive=true
    }
}

In order to get directions between two geo location points use the code below

// Downtown LA
Waypoint origin = new Waypoint(-118.24233, 34.05332);

// Santa Monica Pier
Waypoint destination = new Waypoint(-118.49666, 34.01114);

// Build the client object
MapboxDirections client = new MapboxDirections.Builder()
    .setAccessToken(MAPBOX_ACCESS_TOKEN)
    .setOrigin(origin)
    .setDestination(destination)
    .setProfile(DirectionsCriteria.PROFILE_DRIVING)
    .build();

// Execute the request
Response<DirectionsResponse> response = client.execute();

DirectionsRoute route = response.body().getRoutes().get(0);
int distance = route.getDistance() // 26446 (in meters)

In order to draw the route on the Mapbox map, do this:

// Convert List<Waypoint> into LatLng[]
List<Waypoint> waypoints = route.getGeometry().getWaypoints();
LatLng[] points = new LatLng[waypoints.size()];
for (int i = 0; i < waypoints.size(); i++) {
    points[i] = new LatLng(
        waypoints.get(i).getLatitude(),
        waypoints.get(i).getLongitude());
}

// Draw Points on MapView
mapView.addPolyline(new PolylineOptions()
    .add(points)
    .color(Color.parseColor("#3887be"))
    .width(5));

Please check this out:

https://www.mapbox.com/blog/android-directions-library/

分享给朋友:
您可能感兴趣的文章:
随机阅读: