Hands on

Pub Crawl with HERE

By Shruti Kuber | 12 September 2018

I am a student in the beautiful city of Berlin! While we had an almost tropical summer this year, on any given day, I had two major goals. First, chill by the river during the day. Second, enjoy the nightlife of Berlin.

While the scorching sun didn’t let me do the former most days, I have my pockets to blame for not letting me do the latter. My friends and I even tried to make a list of awesome but cheaper pubs that we could hop to. Who were we kidding? Berlin is huge and has countless pubs and bars. We were never going to finish that list.


The nerd in me had an idea! Why not make an app which will navigate me through a pocket-friendly pub crawl from wherever I am. It was also empowering to be able to solve every day “problems” with a little bit of coding. I had to figure out a few things though, such as: What does the app actually do? On what device will I be using it? Which APIs do I need. Let's try and answer these questions.


First, the app should be able to locate me on a map, search for pubs around me and navigate me through them. I also have an Android based phone (I wouldn't be searching for cheap pubs if I could afford an iPhone). So, I chose the android platform and made sure I had the Android studio set up. Finally, the key points from my ideation were map, location, search and navigate. After going through the documentation, I realized that the APIs I will be needing are:
Interactive Maps : To render a map with features suitable for walking around.
Positioning : To locate myself on the map.
Places : To search for pubs and get their names, location and other details.
Routing : To navigate me through selected points of interest.

Once the ‘Whats’ and ‘Hows’ were answered, it was time to implement. As daunting as it sounds, it can be achieved when done in small steps. To be able to use these APIs, there is a simple process to be followed.

Register for a HERE account with a Freemium plan. Obtain your credentials for the project. (The registered package name must match the package name in your Android project.) Download the SDK. All set for your first app!


If you are a novice like me when it comes to making an android app, the Quickstart section will help you render a basic app with as few as 6 steps. You can take another route by downloading the examples and taking one of them as the base of your app. I selected the search example as the base for my app. I went through the code and identified the changes I would need to make.
Adding functions
Tip: Adding the functional modules one by one makes it easier to debug in case you get a bunch of incoherent errors! First, be sure to add a way to ask permissions for using location in the app. You wouldn’t want to violate the users’ privacy. You can do this by creating a request for asking permissions, and then start the main body of the application only if the permissions are accepted.

So, let’s go ahead and add all four elements one by one.

  1. Rendering a map
    If you start the project with Quickstart or downloading an example like I did, the map will be already rendered. As it is an app that aims at navigating the user on foot, I added some customization for the map scheme, details like the crosswalks, bridges, stairs and tunnels to make it suitable for a pedestrian use case. I also added the co-ordinates to center the map in Berlin. If you are making the app from scratch, and want to explore more features of the map, you can follow the documentation on Interactive Maps and customize your map fragment with numerous elements
  2. Locating
    Locating yourself on the map is as essential as rendering the map itself. Imagine having a stretched-out paper map in your hand, but no idea where you are on the map. You still wouldn't know where to go. Where am I?A PositioningManager is a class that manages information collected from positioning devices like speed, location updates etc. and can be used to get current location as well as changes in the current position. Create an instance of the PositioningManager. The PositioningManager collects position information in 3 ways.
    • GPS- the GPS chip in your phone receives information from satellites which is used to calculate the position.
    • Network- Your proximity from the network towers is calculated to give a position.
    • Combination of GPS and Network- Both the above methods are used for better accuracy.
    I used a combination of GPS and Network and marked the position with a marker. Set your map to center at your current location. I added a cool animation so that the map swooshes over to my location. Check out other map animation options here. Done, you now have your current location in the variable currentLocation.
  3. Searching
    The main functionality of this app lies is searching for places with the right query and sorting the results according to your requirement. The Places API provides us with 4 options to perform the Search and Discovery:
    • Search: Finds a place that match user-defined search terms.
    • Explore: To find interesting places around a location which can be filtered with types of places.
    • Here: To identify places you are already at, to be able to perform check-ins etc.
    • Around: This type of request is intended for applications that employ features such as augmented reality, where places around the user's location are displayed on a device.
    I chose to use the Search class to search for pubs around me. Although the CategoryFilter has many pre-defined search options like EAT_DRINK, SHOPPING etc., I chose to search with the help of a search string. I limited the result list to 5 results and restricted the search area to a radius of 5km. Once you have framed your request, you can invoke it by calling Here the discoveryResultPageListener is the listener that will handle the result of your request. The result is a DiscoveryResultPage object which represents a paginated collection of items. Depending on your request, the result can be of several such pages. When additional pages of search results are needed, retrieve and invoke the DiscoveryRequest returned by DiscoveryResultPage.getNextPageRequest(). The listed items on these pages can be either a PlaceLink or DiscoveryLink. The PlaceLink can be used to retrieve place details by firing another PlaceRequest. Check the documentation on PlaceRequest.
    I stored the results of my search query and placed some martini glasses to identify these places - because, why not? Martini glasses
  4. Navigating

    After having the list of places I wish to go to, I want to navigate to them from my current position. Ordinarily, If I know where I am going, I will try to figure out the route I will be taking. If I have more than one destination, I will try to select the route that covers all of them while considering the traffic on the route and overall length of the route.

    The CoreRouter class does exactly the same for you. It is responsible to calculate routes with cars, trucks, public transport, trucks, scooters, intermodal and pedestrian routing. It requires a plan of your destination with the list of desired stopovers and this can be done with the help of class RoutePlan.

    A RoutePlan is a container that holds your destinations or Waypoints as they are called here and routeOptions. RouteOptions includes parameters like number of routes expected, mode of transport, direction of travel, routing type- fastest/ shortest. You can add your destinations and stopovers using RouteWaypoint. Once your query is set up, you can request the calculated route by calling the CoreRouter.calculateRoute(RoutePlan, CoreRouter.Listener) method.

    The Router.Listener has to be written in a way to handle the result of the routing request. The RouteResult class represents a route calculation result. It consists of the Route class which is a distinct calculated path connecting two or more waypoints, consisting of a list of maneuvers and route links.
    After the route is calculated, it has to be displayed on the map. For this, we have the MapRoute class which is a type of MapObject that displays a calculated route on a map. Wut?
    This jargon has already fried my brains. Let us break it down step by step.
    Mode of Transport
    As this is an app for a pub crawl, I chose pedestrian routing as you should not drive when you are drinking.

    You can also add an option to mix up public transport and pedestrian routing. (Although if you do have a designated driver, you can opt for adding car routing.) There are several route options that you can select to customize your route. You can read about them here. Set other parameters like number of routes and fix your route options. Adding waypoints
    Add the waypoints to the route which should consist of your current location and the location of the places collected in the place result list. The route plan is now ready to calculate the route by calling the function below. Listener
    The listener should handle the above request by storing the calculated route and displaying the MapRoute on the map. Don't forget to handle instances where no route is returned due to various reasons like- too many filters, no connecting route etc. To make things easier, I reused the code for the listener which can be found in the routing example on GitHub.
    This concludes all the elements of the app. \o/

Screen Shot 2018-08-28 at 1.19.37 PM

And that’s how I made my first app using HERE Android SDK. Now this is just a plain version and I am sure you will be able to make a cooler version of this which has more functionalities. What would be interesting is to explore all the parameters of the various classes and customize the app for an amazing user experience. You can add intermodal routing by using a combination of public transport and pedestrian routing. That way you could increase the radius of your search. You could add external references like yelp to your places by using

You can add voice instructions with turn by turn navigation. You can also make the app responsible for counting the number of drinks you've had. There is so much you can do. So, go ahead and create your pub crawl app with developer.here.com!