tyczj / mapnavigator Goto Github PK
View Code? Open in Web Editor NEWEasy to use library to get and display driving directions on Google Maps v2 in Android
License: Apache License 2.0
Easy to use library to get and display driving directions on Google Maps v2 in Android
License: Apache License 2.0
Hi,
This library is quite good. I am a newbie to android and trying to learn the new maps apiV2.
I am experimenting with your library: I would like to know how to you get the distance and duration for path.
I am having some troubles. The directions returned is always null. Can you help me how to use the api to retrieve the distance and duration.
This is how I tried to retrieve the distance:
Navigator nav = new Navigator(googleMap,start,end);
nav.findDirections(true);
String strDis;
Directions directs = nav.getDirections();
if(directs != null){
strDis = nav.getDirections().getRoutes().get(0).getDistance();
strDis +="inHere";
}
else{
strDis ="none";
}
I also tried using the Interface
@OverRide
public void onPathSetListener(Directions directions) {
if(directions != null){
String strD = directions.getRoutes().get(0).getDistance();
mDistanceView.setText(strD);
}
}
I'm implementing a map inside a viewpager, the problem is that polylines are not drawn on the map.
The Route returned has null startLoc and endLoc, I found that the tags for them "start_location" and "end_location" are actually in Legs
Is it possible to use this library to add more than one destination (or waypoints)? If so how can i do this?
Am I going to run into a usage problem. As in if I have this updating every couple of minutes I'll hit a quota of sorts and then no longer be able to use this library or does it have an unlimited amount of uses? I'm just asking because I would hate to release this and then run into people complaining that the directions aren't working because they used the crap out of it that month and that user hit their quota of uses for that month. Just curious.
By the way I checked this out this morning very slick job thank you for this it awesome. I love the simplicity of it I wish Google would have done something like this in the first place when they created the freaking thing. To make it easier on the Developer.
Hi, thanks for this library that works perfect. I have a question and i hope you can get me into the right way.
I draw a route from two point (fixed), and clicking in the infoview the route (polyline) will drawn into the map and it works. By the way i have 20 different marker, and i want to draw a route only when click on the infoview. I mean, if there is already a route in the map, clicking in one other infoview, this route have to be removed and the new one has to be added in the map.
I have a Switch-case method to call each route by clicking in the infoview of the marker, this is a snippet of my code:
switch (markerIndex){
case 0:
start = new LatLng(22.28861858, 11.32771726);
end = new LatLng(22.48861858, 11.36779726);
Routing routing = new Routing(Routing.TravelMode.WALKING);
routing.registerListener(ActivityOutdoor.this);
routing.execute(start, end);
break;
case 1:
start = new LatLng(21.48861858, 11.32771726);
end = new LatLng(23.48861858, 13.36779726);
Routing routing1 = new Routing(Routing.TravelMode.WALKING);
routing1.registerListener(ActivityOutdoor.this);
routing1.execute(start, end);
break;
default:
break;
}
Do you know how to remove the previous route, when click the other infoview?
I used map.clear(); but it will delete all the content of the map
Thanks in advance
Brus
Hey, love the library and I have used it in an application & when I push the update to Store, I'll credit you. Just wanted to know if you could add it so that the previous routes are cleared on Map once we created a new one. Thanks.
I have a strange bug on Android 5.0 - 5.1.1 with getting routes from maps.googleapis.com/maps/api/directions/json.
With Android 4.0 - 4.4.2 everything works perfect!
The only useful crashlog until now was:
java.lang.IllegalArgumentException
at android.os.Parcel.nativeAppendFrom(Native Method)
at android.os.Parcel.appendFrom(Parcel.java:440)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1300)
at android.os.Bundle.writeToParcel(Bundle.java:1096)
at android.os.Parcel.writeBundle(Parcel.java:663)
at android.location.Location.writeToParcel(Location.java:912)
at android.os.Parcel.writeParcelable(Parcel.java:1357)
at android.os.Parcel.writeValue(Parcel.java:1262)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:638)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
at android.os.Bundle.writeToParcel(Bundle.java:1096)
at android.os.Parcel.writeBundle(Parcel.java:663)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:2901)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3290)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Can anyone else reproduce this bug?
Thanks in advance!
I want to know one kind of navigation is just making path between two points and second is while you are traveling in car along the path it will guide you your current location on path with right and left directions. So i want to ask what are the capabilities of this library regarding both scenarios?
Great job dude, thanks alot for sharing this :)
There is no mainactivity in your github sample. Can you update the sample as a working sample in android? These four classes are not helping at all
while search for mumbai using this library route is not display properly.
it is really a very good job and i have tried your library and it works 100% fine, but i am trying to get a list of geopoints of the route so the first step is that i try to get the directions by Directions dir = nav.getDirections() but it returns null. can you please help me.
Thank you.
Hello, was wondering how to call the getDuration() method in the Route class and will it return the total time of the trip? Thank you.
How to set the nav.setMode() ?
Can you please give an example ?
It says setMode(mode, arrivalTime, avoid);
how to set the parameter ?
I am new to this , so please help me.
what's wrong with my code :
Route route;
final Navigator nav = new Navigator(map, myLocation, Destination);
nav.findDirections(false);
nav.setOnPathSetListener(new OnPathSetListener() {
@OverRide
public void onPathSetListener(Directions directions) {
// TODO Auto-generated method stub
route = directions.getRoutes().get(0);
txt.setText("dist: "+route.getDistance());
}});
the result is this : "dist: null"
I am using SupportMapFragments in my application and it is crashing when implementing the library calling it as described in the readme. Could this be why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.