I try to get Map route between two places in android and i refered this Link, here
but its showing error at this two places,
HttpClient oHttp = HttpClient.getInterfaces();
String szXml = oHttp.doGet(szUrl,"");
how to solve this
Related
I am making an android app where it will collect the overview_polyline->points string from the google maps api. For testing sake i have directly copied it(overview_polyline->points) and used as shown in the below code. I am using Polyutil to decode it:
List<LatLng> list = PolyUtil.decode("yxkpA_sjgMoAXuA#{GHeAFo#Jg#P[FcDHiCFu#B}#DkATiAFi#Hw#FcAKmAA[zG#n#DjAFpAPhB`#vBRt#`#|#dAbCg#F{B?eA?BpAAjC?vAC^W|#Ir#GdBe#hCm#lDpCl#|D~#J#?`AHdEAxGAVGZe#jBOnBzDLnGWPDFNRjDAjAG~#S|CCn#v#BXF?`#LtBEHOESC[BKBIJWWA?#?VV?PDbACJB?d#Ix#MRhBANABXRNDx#BBD#VD#FAj#?NB|#HAZLtBAf#CR");
I got the string from the below google direction api result:
"overview_polyline" : {
"points" : "yxkpA_sjgMoAXuA#{GHeAFo#Jg#P[FcDHiCFu#B}#DkATiAFi#Hw#FcAKmAA[zG#n#DjAFpAPhB`#vBRt#`#|#dAbCg#F{B?eA?BpAAjC?vAC^W|#Ir#GdBe#hCm#lDpCl#|D~#J#?`AHdEAxGAVGZe#jBOnBzDLnGWPDFNRjDAjAG~#S|CCn#v#BXF?`#LtBEHOESC[BKBIJWWA?#?VV?PDbACJB?d#Ix#MRhBANABXRNDx#BBD#VD#FAj#?NB|#HAZLtBAf#CR"
},
When i run the app it says java.lang.StringIndexOutOfBoundsException: length=268; index=268
I want to make this task and I´ve found some libraries to do that here by tyczj and here by akexorcist. These are good solutions but this libraries use httpClient and currently is deprecated, is there others?. Thanks.
It could be useful.
Make your own http request to get directions information from The Google Directions API and get overview_polyline string from response.
Decode the string using android-maps-utils library with PolyUtil.decode method.
Add decoded points to map:
List<LatLng> decodedPoints = PolyUtil.decode(polylineString);
PolylineOptions options = new PolylineOptions();
options.width(6);
options.color(Color.RED);
options.addAll(decodedPoints);
map.addPolyline(options);
I want to create a route map navigation in Android google map v2 along with all those details which google provides( like at this crossing you have to turn left). I know this can be done using a parsing techniques i have done that but what im looking for is, is there any new method predefined within android v2 google map which will give all these details and will show the route map within two points.
Again Im mentioning it not using the JSON parsing technique. anything newly implemented for v2
Any sample projects or examples is very much helpful.
thanks
Without using json parsing technique to draw routes can be done by one method linking to google navigation by doing stuff like this.
String address = marker.getTitle();
Intent intent;
if (address == null) {
LatLng pt = marker.getPosition();
String lat = Double.toString(pt.latitude); //this i mentioned with current location
String lng = Double.toString(pt.longitude);
intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("google.navigation:q=" + lat + "," + lng));
However for Google map direction, json parsing is best.
No, there is only the Google Directions API available for a route response, which includes JSON parsing.
Is it possible not only to have Google Maps on Android show a given coordinate in the Maps Application but have also a marker (or pin) set at the location?
I read the documentation at https://developer.android.com/guide/appendix/g-app-intents.html but it only lets me set the zoom level.
Right now I use the following code to show a place in Google Maps on Android:
Double lat = 53.3;
Double lng = 13.4;
final String uriString = "geo:" + lat + ',' + lng + "?z=15";
Intent showOnMapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString));
startActivity(showOnMapIntent);
Is it possible to have a marker there or do I need to use a MapActivity?
Where can I find the complete documentation on the url parameters that the Maps application understands?
Can I use a different url prefix? For example "https://maps.google.de/maps?"?
Maps has an intent-filter matching this scheme/host/pathPrefix.
Where can I find documentation on which parameters Google Maps for Android actually supports with this url?
Dirk, have you tried geo:0,0?q=lat,lng?
it is displaying a marker on my nexus 5.
It works with the follwoing url:
final String uriString = "http://maps.google.com/maps?q=" + lat + ',' + lng + "("+ label +")&z=15";
The reverse geo coded address is shown.
I found documentation to the supported parameters here. This is not the documentation for Androids Google Maps but what I tried works.
Note: it should be noted that the original question was in regards to the the geo: URI to launch the Google Maps app (see Android Developer Reference Intents List, whereas this answer might launch a web view with the Google Maps website depending on what App the user chooses for this Intent.
try this:
http://maps.google.com/?saddr=34.052222,-118.243611
and to get the complete route between two points:
http://maps.google.com/?saddr=34.052222,-118.243611&daddr=37.322778,-122.031944
This is a question about Mapquest Android Maps API.
Does anyone know that the createRoute method is supporting lat/Lng or not in mapquest?
public void createRoute(java.lang.String from, java.lang.String to)
The document I found here:
I have read the "Location Format Documentation" : link
It seems that createRoute method supports lat/Lng.
I tried to input lat/Lng a whole day but it returns me an error message only:
Unable to create route.
Error: -1"
Message:[null]
Are you still seeing this error message? The MapQuest Android Maps API does support lat/lng input for routing. Here is a sample request that uses lat/lng inputs:
private void displayRoute() {
RouteManager routeManager= new
RouteManager( this );
routeManager.setMapView( map );
routeManager.createRoute( "{latLng:{lat:37.765007,lng:-122.239937}}" , "Fremont, CA" );
}
Also, The MapQuest Developer Network has an Android Maps API forum. It is also a good resource to check!
You can write like this
RouteManager routeManager = new RouteManager(this);
routeManager.setMapView(map);
routeManager.createRoute("37.002004,35.322998", "36.802687,34.632812");
or like this
RouteManager routeManager = new RouteManager(this);
routeManager.setMapView(map);
routeManager.createRoute("Any City Name", "Any City Name");
MapQuest is supporting this types