Closed donaldhuebner closed 10 years ago
I have not tested this with SupportMapFragment (really forgot it existed to be honest) what is the error you get?
It probably has to do with using SupportMapFragment though.
paste the stack trace here
10-23 14:54:23.590: W/System.err(20136): org.json.JSONException: Index 6 out of range [0..6)
10-23 14:54:23.590: W/System.err(20136): at org.json.JSONArray.get(JSONArray.java:263)
10-23 14:54:23.590: W/System.err(20136): at org.json.JSONArray.getJSONObject(JSONArray.java:480)
10-23 14:54:23.590: W/System.err(20136): at com.tyczj.mapnavigator.Legs.parseSteps(Legs.java:28)
10-23 14:54:23.590: W/System.err(20136): at com.tyczj.mapnavigator.Legs.
Hope this helps I'm still a bit of a newbie.
ahh I see the problem, to fix it quick just set implement a listener for OnPathSetListener and it should work
example nav.setOnPathSetListener(this); and in your activity implement OnPathSetListener.
I will put a fix in to check to see if this was set or not
I tried that too before contacting you and I may have put it in the wrong place. Okay I'll put that in the same place where I'm calling the lib. Thank you.
THANK YOU FIXED. I swear I tried that reading your directions clearly. I had to set a new onPathSetListner I guess because of where I have it in the code. FIXED though after two days. Thank you.
Thank you.. mine looks like this.. I get the first latlng and second somewhere else.
//googleMap.animateCamera(CameraUpdateFactory.zoomTo(12)); //googleMap.addMarker(new MarkerOptions().position(latlng2)); Navigator nav = new Navigator(googleMap, latlng, latlng2); nav.findDirections(false, false); nav.setOnPathSetListener(new OnPathSetListener() {
@Override public void onPathSetListener(Directions directions) { // TODO Auto-generated method stub
}
I've implemented it up at the top of the class this is in and it autogenerated the methods but since I created a new listener I don't believe it is using it. It works though and not fooling with it. Learning new crap everyday. Thank you again.
yes that is the other way of doing it. glad to hear it works
I noticed it does place the polyline all the way on the road exactly. Is there a way to get more lat long points to place the line closer on the road?
Traveling from on city to another seems to cause this it taking interstates.
I am not sure I understand what you mean?
Sorry after reading back over that. The poly line it draws on the map does not closely match the road when traveling on interstates. It seems to get an array of latitude and longitude points which is spread out more than needed. Is there a way to bump up the amount of lat long points to make it follow the road better? I noticed if the location is close to the interstate it just pops the line over to the location and doesn't take the exit. I'm trying to calculate travel times and I know this will be wrong by it reporting this.
I just parse what google returns to me so there is no way of adding more points or whatever. I never had a problem with the line not following turns on interstates or highways on anything I tested though. It might be just google does not have good data there?
Hmm.. okay. I wonder why the fragment is doing that.. If I query the same on a google application, like maps, the map looks fine. Thank you for all your help.
What are the LatLng points you are using?
I thought maybe it was in walking mode, then I saw your default. Same even after forcing it. I'm using google autocomplete for 1904 McConnell Ave, evansville, in, united States to Walmart Supercenter, park plaza drive, Secaucus, NJ, united states. I geocode to get the lat lng and not sure how to see the numbers to give you an exact.
public void onClick(View v) {
String value = autoCompView2.getText().toString();
List
nav.findDirections(true, true);
nav.setPathLineWidth(2);
nav.setOnPathSetListener(new OnPathSetListener() {
@Override
public void onPathSetListener(Directions directions) {
googleMap.addMarker(new MarkerOptions().position(latlng2));
}
});
you are right it does give weird directions with those coordinates for some reason, even If I use points I get by tapping on the map at those locations it does weird stuff. However if I tap on the map at other locations the route displays fine. I even tested cross state points and the showed fine...something must be weird with those points :/
Cool, glad I'm not the only one who sees it. I would appreciate it if you think of something and tell me. I'll do the same but I think I'm going to take my phone outside and wrap it in some C4. lol. Thanks man.
Maybe the reason is the polyline is drawn based on overview_polyline / points and not all the steps / polyline / points?
@mg6maciej If I use the steps polyline I only get a small segment of the path. Using the 2 points that @donaldhuebner gave me I only get 8 steps back from google
How about concatenating all the points from all the steps of a single route?
bah I found the problem, just pushed the update that fixes it
Great. Glad I could help a bit.
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?