GraphHopper.com | Forum | GitHub | Maps | Blog

How to add search bar in offline graphhopper?


#1

I want a search bar at the top of the screen that suggests places then when searched, the map will change map position based on what they search. I have a manila-gh folder for offline.

I’m working with android studio


#2

That’s a more Android development question than closely related to GraphHopper. :slight_smile:
So you’ll find more info in Android documentation guides, for how to use e.g. edit texts.

Regarding actual search (aka Geocoding), there is a GraphHopper online solution to check and for offline a properly structured DB would probably suffice.


#3

Given that I’ve actually coded the search layout. What should i put in DB? I’ve seen this code. How do I call it in the search bar if in case the user managed to search the location. Does the files in the Downloads folder(the -gh folder) supports geocoding so it can be done offline? Thank you!


#4

Files in -gh folder can contain two kinds of data:

  • Mapsforge offline vector maps, for map viewing (not suitable for search)
  • GraphHopper offline graphs, which can be used for routing

So for an offline geocoding solution I think we need a new data structure, as a DB.

If I may post a hint, there is Mapsforge POI API which you can check (and discuss in its forum).


#5

Okay thank you. I’ll research on that!


#6

btw if it’s online, how do i implement the geocoding?


#7

If you’re referring to Mapsforge POI API, it’s offline using SpatiaLite.


#8

This should be already implemented in the java api client. There is geocoding method. You only have to call this method. BTW: You need to signup for an API Key at graphhopper.com.


#9

Hello, i have the API key already and i’ve checked this java file. How do i get all the string names and geopoints of this using the API key?


#10

You are looking in the wrong file ;). Here are some examples from the client tests: https://github.com/graphhopper/directions-api-java-client/blob/master/geocoding/src/test/java/com/graphhopper/geocoding/client/api/GeocodingApiTest.java

For that you have to use the client and not graphhopper itself.


#11

Oh thank you! I’ve tried adding this to my dependency compile "com.graphhopper:directions-api-java-client-geocoding:0.9-SNAPSHOT" but it won’t build.


#12

Not sure if that version exists https://mvnrepository.com/artifact/com.graphhopper/directions-api-java-client-geocoding