When was the last time you were truly lost? Thanks to the maps and location technology in our smartphones, a whole generation has now grown up in a world where getting lost is truly a thing of the past.
Location technology goes far beyond maps in the palm of our hand, however. Today it is at the heart of a broad range of applications, from logistics to games, from social networks to ridesharing.
In this talk, we will explore how a ridesharing app works. We will ask questions such as: How do we find out where the passenger is located? How do we discover our destination? How do we find the closest driver? How do we provide a correct ETA to the passenger in heavy traffic? How do we display this information on a map? How do we find the best route to the destination?
To answer these questions, we will be learning about a variety of location APIs, including Maps, Positioning, Geocoding, Routing, Traffic, Places, and much more.
At the end you should be able to build your own ridesharing app or any clever app for which location matters.
26. We are currently at 40.728215, -73.958251. What does that mean?
Latitude & Longitude
Latitude Longitude
Equator
Prime Meridian
+60
-30
-90 (South)
+90 (North) 180
-120 (West)
+30 (East)
51. "Where are the drivers?"
Pickup: 72 Noble St, Brooklyn
Positioning API
52. "Where am I going?"200 Central Park W
Pickup: 72 Noble St, Brooklyn
53. "Where am I going?"200 Central Park W
Pickup: 72 Noble St, Brooklyn
200 Central Park W, New York
200 Central Park S, New York
200 Central Park N, New York
200 Central Ave, Brooklyn
54. Geocoder
Autocomplete API
200 Central Park W
Pickup: 72 Noble St, Brooklyn
200 Central Park W, New York
200 Central Park S, New York
200 Central Park N, New York
200 Central Ave, Brooklyn
"Where am I going?"
56. {
"suggestions": [
{
"label": "United States, NY, New York, 200 Central Park W",
"language": "en",
"countryCode": "USA",
"locationId": "NT_srx4m-dHrwiUBDnXi3NAwD_yADM",
"address": {
"country": "United States",
"state": "NY",
"county": "New York",
"city": "New York",
"district": "Upper West Side",
"street": "Central Park W",
"houseNumber": "200",
"postalCode": "10024"
},
"matchLevel": "houseNumber"
},
{
"label": "United States, NY, New York, 200 Central Park S",
...
},
...
]
}
57. "Where am I going?"american museum of
Pickup: 72 Noble St, Brooklyn
American Museum of Natural History
American Museum of the Moving Image
Museum of the American Gangster
Museum of Chinese in the Americas
58. Places API
american museum of
Pickup: 72 Noble St, Brooklyn
American Museum of Natural History
American Museum of the Moving Image
Museum of the American Gangster
Museum of Chinese in the Americas
"Where am I going?"
59. DiscoveryRequest request = new SearchRequest("american museum of");
GeoCoordinate manhattan = new GeoCoordinate(40.71451, -74.00602);
request.setSearchCenter(manhattan);
request.setCollectionSize(5);
request.execute(new SearchRequestListener());
class SearchRequestListener implements ResultListener<DiscoveryResultPage> {
@Override
public void onCompleted(DiscoveryResultPage data, ErrorCode error) {
List<DiscoveryResult> items = data.getItems();
for (DiscoveryResult item : items) {
PlaceLink placeLink = (PlaceLink) item;
// display information
}
}
}
60. DiscoveryRequest request = new SearchRequest("american museum of");
GeoCoordinate manhattan = new GeoCoordinate(40.71451, -74.00602);
request.setSearchCenter(manhattan);
request.setCollectionSize(5);
request.execute(new SearchRequestListener());
class SearchRequestListener implements ResultListener<DiscoveryResultPage> {
@Override
public void onCompleted(DiscoveryResultPage data, ErrorCode error) {
List<DiscoveryResult> items = data.getItems();
for (DiscoveryResult item : items) {
PlaceLink placeLink = (PlaceLink) item;
// display information
}
}
}
61. DiscoveryRequest request = new SearchRequest("american museum of");
GeoCoordinate manhattan = new GeoCoordinate(40.71451, -74.00602);
request.setSearchCenter(manhattan);
request.setCollectionSize(5);
request.execute(new SearchRequestListener());
class SearchRequestListener implements ResultListener<DiscoveryResultPage> {
@Override
public void onCompleted(DiscoveryResultPage data, ErrorCode error) {
List<DiscoveryResult> items = data.getItems();
for (DiscoveryResult item : items) {
PlaceLink placeLink = (PlaceLink) item;
// display information
}
}
}
62. "How long does it take?"
"How much does it cost?"
american museum of
Pickup: 72 Noble St, Brooklyn
American Museum of Natural History
American Museum of the Moving Image
Museum of the American Gangster
Museum of Chinese in the Americas
63. "How long does it take?"
"How much does it cost?"
Confirm ride
28 min - $24 - $29
64. Routing API
"How long does it take?"
"How much does it cost?"
Confirm ride
28 min - $24 - $29
65. CoreRouter router = new CoreRouter();
RoutePlan routePlan = new RoutePlan();
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1966286, -123.0053635)));
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1947289, -123.1762924)));
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new RouteListener());
66. CoreRouter router = new CoreRouter();
RoutePlan routePlan = new RoutePlan();
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1966286, -123.0053635)));
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1947289, -123.1762924)));
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new RouteListener());
67. CoreRouter router = new CoreRouter();
RoutePlan routePlan = new RoutePlan();
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1966286, -123.0053635)));
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1947289, -123.1762924)));
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new RouteListener());
68. CoreRouter router = new CoreRouter();
RoutePlan routePlan = new RoutePlan();
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1966286, -123.0053635)));
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1947289, -123.1762924)));
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new RouteListener());
69. CoreRouter router = new CoreRouter();
RoutePlan routePlan = new RoutePlan();
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1966286, -123.0053635)));
routePlan.addWaypoint(new RouteWaypoint(
new GeoCoordinate(49.1947289, -123.1762924)));
RouteOptions routeOptions = new RouteOptions();
routeOptions.setTransportMode(RouteOptions.TransportMode.CAR);
routeOptions.setRouteType(RouteOptions.Type.FASTEST);
routePlan.setRouteOptions(routeOptions);
router.calculateRoute(routePlan, new RouteListener());
70. private class RouteListener implements CoreRouter.Listener {
public void onProgress(int percentage) {
// Display a message indicating calculation progress
}
public void onCalculateRouteFinished(List<RouteResult> routeResult,
RoutingError error) {
mapRoute = new MapRoute(routeResult.get(0).getRoute());
map.addMapObject(mapRoute);
updateTextView(routeResult.get(0).getRoute().getLength());
}
}
71. private class RouteListener implements CoreRouter.Listener {
public void onProgress(int percentage) {
// Display a message indicating calculation progress
}
public void onCalculateRouteFinished(List<RouteResult> routeResult,
RoutingError error) {
mapRoute = new MapRoute(routeResult.get(0).getRoute());
map.addMapObject(mapRoute);
updateTextView(routeResult.get(0).getRoute().getLength());
}
}
72. private class RouteListener implements CoreRouter.Listener {
public void onProgress(int percentage) {
// Display a message indicating calculation progress
}
public void onCalculateRouteFinished(List<RouteResult> routeResult,
RoutingError error) {
mapRoute = new MapRoute(routeResult.get(0).getRoute());
map.addMapObject(mapRoute);
updateTextView(routeResult.get(0).getRoute().getLength());
}
}
73. ...
"length": 9919,
"travelTime": 1664,
"maneuver": [
{
"position": {
"latitude": 40.728361,
“longitude": -73.9582743
},
"instruction": "Head toward West St on Noble St. Go for 79 m.",
"travelTime": 15,
"length": 79,
"id": "M1",
"_type": "PrivateTransportManeuverType"
},
{
"position": {
"latitude": 40.7282925,
"longitude": -73.9590061
},
"instruction": "Turn right onto West St. Go for 239 m.",
...
87. $28.27
Thanks for riding with HERE, Richard!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac mi a
sem viverra lobortis. Donec at massa vel nibh lobortis laoreet. Orci varius
natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Praesent finibus facilisis nisi, id consectetur eros scelerisque non.
Suspendisse ut ligula interdum, dictum velit vel, interdum erat. Sed
vulputate laoreet tempus. Sed varius felis sed lorem semper commodo.