Typically when the user is driving to a point-of-interest (POI) they would actually require navigation to a nearby location such as a parking lot or an access point. Picture a driver that needs to go to an airport or a shopping mall. When going to an airport the driver is trying to reach a terminal or a drop-off point rather than the center of the airport compound. Likewise a parking lot next to the shopping center might be a much better option for a user with a car. In this case when developing an app or a service to guide the driver, first find the location they are going to and then offer the driver optional destinations near that location. This approach allows you to provide better service to your customers and demonstrate that you value their time, with a small but smart development effort that leverages location data provided by Google Maps Platform.
We will show how you can use Places API and Directions API in sequence or combination to identify the right location to park next to your destination. This solution aims to remove uncertainty and multiple interactions to find a spot to park while driving once closer to the end destination. Let's look at two examples of how these cases could be implemented in detail.
Example 1 - a tourist attraction with no parking lot
Let’s pick a location that is not directly connected to the roadside so that a route must be retrieved separately, the destination is Notre Dame in Paris and as a starting point let’s use the Gare de l’Est railway station (48.87697775149635, 2.3592247806755564).
The driver leaves the station about 16 minutes north of Notre Dame. Notre Dame is a famous tourist attraction on an island with bridge access, some one-way streets and no large parking lot available nearby, so this should be an interesting challenge.
Places API request
This example Places API request is using “text search” to find Notre Dame. See the developer documentation for details. The “YOUR_KEY” in these examples is the API key you have for the Google Maps Platform Places and Directions APIs enabled in the Google Cloud Console. For a more detailed explanation please see the documentation for getting started with Google Maps Platform.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=notre_dame&location=48.864716%2C2.349014®ion=fr&key=YOUR_KEY
The response to the above request gives the following latitude & longitude coordinates:
"results" : [ { "formatted_address" : "Notre Dame, Paris", "geometry" : { "location" : { "lat" : 48.8527288, }, ...
As you can see, the coordinates indeed pinpoint Notre Dame.
|
|
As a developer or a service provider, it’s a good idea to automatically prompt the driver “Looking for parking near Notre Dame?”. The user experience will be different depending on the device and screen, but a subtle popup text that disappears after a short time could be worth considering in this case. To find parking near Notre Dame, do a Places API text search with type “parking” and radius “300” parameters set. This example will bias the results to parking areas within 300 meters of Notre Dame.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=parking
&location=48.8527288%2C2.3505635®ion=fr&type=parking&radius=300&key=YOUR_KEY
The first result is “Parking Saemes Maubert-Lagrange” at 48.850591, 2.3486436. Let’s use this location in the next part where we are doing a Directions API request.
Directions API request
To find the route from the station to a parking area close to Notre Dame, you need to do a Directions API request. Just set the origin and destination parameters. See developer documentation for more options.
https://maps.googleapis.com/maps/api/directions/json?origin=48.8767903,2.3592251&destination=48.850591%2C2.3486436&key=YOUR_KEY
Direction API response typically contains multiple route suggestions. Each route consists of multiple “legs” and those contain multiple “steps” showing traveling distance and coordinates. To find the final coordinates reachable with a car, use the “end_location” field of the last step of a last leg in a route you selected.
This location may seem like not the first choice, but when you look at the map or Google Street View, you will find that this location is within a very short walking distance, about 6-7 minutes, from Notre Dame.
Walking route from parking area to Notre Dame
Summary for example 1
As you can see, finding a parking area for a car requires only a few API calls and displaying the suggestion to the driver. This saves time for your users as they are not driving around on one-way streets or trying to find a place to leave the car in a crowded tourist attraction. As a summary we did the following API requests:
- A Places API request to find Notre Dame coordinates
- A Places API request to find a parking area within 300 meters of those coordinates
- A Directions API request to find a route to the parking area
Example 2 - Guiding to a terminal in a large airport
"types" : [ "airport", "point_of_interest", "establishment" ],
However, anyone who has visited any large airport knows that it takes a significant amount of time to transfer between terminals if you happen to arrive at the wrong location. In this case, since the type of the search result is “airport”, it is useful to automatically follow up query to search for “terminal” using the location of the London heathrow airport (51.47016927594547, -0.45432767852489075). In the example you can also see the optional limitation of search radius of 3000 meters.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=terminal&location=51.47016927594547%2C-0.45432767852489075®ion=gb&key=YOUR_KEY&radius=3000
The query above gives us a list of the terminals and individual drop-off points at those terminals. From the list of results we can find “London Heathrow Airport Terminal 5” and its place id:
"place_id" : "ChIJtQRd6XVxdkgRTUGZtcsoGNc",
Using the “place_id” parameter we can tell the Directions API that we are trying to reach a place rather than some arbitrary coordinates.
https://maps.googleapis.com/maps/api/directions/json?origin=51.557263604707224,-0.2794575145680608&destination=place_id:ChIJtQRd6XVxdkgRTUGZtcsoGNc&key=YOUR_KEY
Again, like in the previous example, by reading all the steps in the JSON response you will find the last part of the journey and the end locations lat & long coordinates (51.47079979999999,-0.4896765).
Summary for example 2
Like in the previous example, the development effort to provide improved guidance to the driver is very small and the benefits in time saved to the driver are easily measured. We did the following requests:
- A Places API request to find Heathrow airport
- A Places API request to find all terminals close to Heathrow airport coordinates
- A Directions API request to get a route to terminal 5
Conclusion
As you can see, the development effort required to provide a premium service to your customers traveling by car is rather small and allows you to easily demonstrate how you are thinking about your customers’ needs.
For development purposes you can use many of the libraries and tools available to help you build the services for your customers. Have a look at our publicly available GitHub repository for Google Maps Platform.
Next Actions
Principal author
Mikko Toivanen | Google Maps Platform Solutions Engineer