Pedestrian route Example
Calculate pedestrian route between origin and destination.
import os
from here_location_services import LS
from here_location_services.config.routing_config import ROUTING_RETURN
from here_map_widget import Map, Marker, GeoJSON
LS_API_KEY = os.environ.get("LS_API_KEY") # Get API KEY from environment.
ls = LS(api_key=LS_API_KEY)
result = ls.pedestrian_route(
origin=[52.51375, 13.42462],
destination=[52.52332, 13.42800],
return_results=[
ROUTING_RETURN.polyline,
ROUTING_RETURN.elevation,
ROUTING_RETURN.instructions,
ROUTING_RETURN.actions,
],
)
geo_json = result.to_geojson()
data = geo_json
geo_layer = GeoJSON(data=data, style={"lineWidth": 5})
m = Map(api_key=LS_API_KEY, center=[52.5207, 13.4283], zoom=14)
origin_marker = Marker(lat=52.51375, lng=13.42462)
dest_marker = Marker(lat=52.52332, lng=13.42800)
m.add_layer(geo_layer)
m.add_object(origin_marker)
m.add_object(dest_marker)
m
Attributes
Attribute |
Type |
Doc |
---|---|---|
origin |
list |
A list of |
destination |
list |
A list of |
via |
list |
A list of |
origin_place_options |
|
optinal place options for |
destination_place_options |
|
optional place options for |
destination_waypoint_options |
|
optional way point options for |
departure_time |
|
optional departure time. |
routing_mode |
string |
optional routing mode is defined in |
alternatives |
int |
optional number of alternative routes to return aside from the optimal route. default value is |
units |
string |
optional representing units of measurement used in guidance instructions, valid values are |
lang |
string |
optional preferred language of the response. The value should comply with the IETF BCP 47, default is |
return_results |
list |
optional list of strings, values are defined in |
spans |
list |
optional list of strings, values are defined in |