GraphHopper.com | Forum | GitHub | Maps | Blog

How to use Graphhopper in Android to get a road line on a map (OpenStreetMap)?


#1

hi,

i want to use this API in android but not understand how to start any one give me idea how i can start my app building with graphhoper API and open street API.


#2

Besides the Routing via Java API guide, there is an Android sample which you can study.


#3

i know this sample . but i want step by step starting that help me to exact understand on use of graphhopper API


#4

how create path between two point???


#5

Please avoid asking questions without investing a bit of your time, nobody here will do this for you and all here invest their spare-time so it should be used wisely :slight_smile:

E .g. try to formulate specific questions when you took the code from the example and copied it into your code. What went wrong, which error message, or screenshot etc


#6

Sorry sir but i really spend many time on open street map and graphopper api.But their is no tutorial provided to use graphhopper with OSM.

i made this application with the help of OSM.

But i want something else like first use of OSM with graphhopper .
2. Draw Route between two point with help of grapphopper.
3. A navigation of that route.
4. Distance between two point,Estimated Time Arrival,Remaining time also Directions.
5. how customize OSM map.

I dont know how use graphhoper api in android and what is its benefit :slight_smile:
how get data from graphhoper and how use it.

what is use of this url?
https://graphhopper.com/api/1/route?point=30.7086243%2C76.727869&point=30.7176455%2C76.7241826&vehicle=car&locale=en&points_encoded=false&key=b759c972-7efd-4cb1-a47f-c12abd018980

and use of its json output ?

Please give me suggestion on these question and how i proceed. thank you in advance :slight_smile:

and the sample you send earlier that never use graphhoper Api.


#7

Do you want online routing with a service hosted from someone else then you have a look here and into the provided Java clients. If you need offline routing then the sample above should help you. Still usage is very similar for both cases.


#8

GraphHopper Android sample is a complete example of how to use the Java API with offline graphs.
Best tutorial is often a working sample covering the library’s features. :smile:

It demonstrates the routing request between two points, how to read the answer, draw the calculated route and retrieve distance / time.
Most of the questions are answered in the sample code, you need to study it.

For the map it uses the Mapsforge offline vector map library.
So to customize the map, you can check Mapsforge forum.


#9

Thank you sir for this sample i get much knowledge. but still this sample has many limitations that i face in it.

  1. sir is their any way to search destination by town/city or postcode.this application uses x,y axis to get latitude and longitude.
  2. As the vehicle travels along the route, the app should show and say directions when
    approaching junctions and roundabouts etc how this will be happen ?

#10

The example shows library’s features, i.e. the routing.

Additional options like geocoding or directions need development by the user with e.g. OSM Nominatim, GraphHopper Geocoding API, Google Text-to-Speech, etc.


#11

Hi, I follow your suggestion in:

GraphHopper hopper = new GraphHopperOSM().forServer();
hopper.setOSMFile(osmFile);
hopper.setGraphHopperLocation(graphFolder);
hopper.setEncodingManager(new EncodingManager(“car”));
hopper.importOrLoad();

But it goes error(in Android) when it comes to:

hopper.importOrLoad();

here is my log:

10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: java.lang.VerifyError: com/graphhopper/reader/OSMInputFile
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.graphhopper.reader.OSMReader.preProcess(OSMReader.java:168)
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.graphhopper.reader.OSMReader.readGraph(OSMReader.java:148)
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.graphhopper.GraphHopper.importData(GraphHopper.java:759)
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.graphhopper.GraphHopper.process(GraphHopper.java:725)
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:698)
10-17 14:28:31.861 32197-774/com.example.administrator.myapplication E/AndroidRuntime: at com.example.administrator.myapplication.MainActivity$6.run(MainActivity.java:628)

could you please tell me what I can do next?


#12

hello parkash sir i am also new to this field and also want to create an app using openstreetmap with graphhopper . i searched a lot about it but only get confused. can u tell me from i should start for this.
Thanks
Jasmeet


How do i used my link to download graphhopper .ghz file?
#14

@jasmeet_sahni Please do not hi-jack topics, instead create a new and show what you have done (like which steps from the docs) and what the problem is that you have.


#15

Hi jasmeet_sahni

Please clear your problem what exactly you want to do and what you done right now.


#16

actually i want to create an android app which uses openstreetmap data and i want to calculate route between two areas.
Also want to show navigation and directions from one place to another with calculated time.
But i am new to this work can anyone suggest me something what can i do or from where i should start my work.
until now i have implemented basic graphhopper sample code but in this it is using europe cities how can i use other countries like india, china.

Thanks in advance