Gene
Gene

Reputation: 21

Turn-by-turn latitude and longitude on HERE Routing API

I want to get the latitude and longitude per instruction on the actions I get from HERE Routing API v8. I get the maneuvers from HERE Routing v7 but not on v8. I tried all the return values.

https://router.hereapi.com/v8/routes?apikey=APIKEY&origin=14.57755,121.04239&destination=14.57735,121.04274&return=polyline,summary,actions,instructions&spans=segmentId&transportMode=car

{
    "routes": [{
        "id": "bae447cc-a31f-48f7-83a7-2c73c34d492d",
        "sections": [{
            "id": "152087e3-7f61-451e-b764-e88583586f10",
            "type": "vehicle",
            "actions": [{
                    "action": "depart",
                    "duration": 10,
                    "length": 76,
                    "instruction": "Head toward Camiguin on Barangka Dr. Go for 76 m.",
                    "offset": 0
                },
                {
                    "action": "continue",
                    "duration": 22,
                    "length": 102,
                    "instruction": "Continue on 9 de Febrero toward Ortigas Ave/Shaw Blvd. Go for 102 m.",
                    "offset": 3
                },
                {
                    "action": "turn",
                    "duration": 12,
                    "length": 53,
                    "instruction": "Turn right onto Talumpong. Go for 53 m.",
                    "offset": 7,
                    "direction": "right",
                    "severity": "quite"
                },
                {
                    "action": "turn",
                    "duration": 29,
                    "length": 149,
                    "instruction": "Turn right onto Tabayog. Go for 149 m.",
                    "offset": 8,
                    "direction": "right",
                    "severity": "quite"
                },
                {
                    "action": "arrive",
                    "duration": 0,
                    "length": 0,
                    "instruction": "Arrive at Tabayog. Your destination is on the left.",
                    "offset": 13
                }
            ],
            "departure": {
                "time": "2022-02-03T18:59:50+08:00",
                "place": {
                    "type": "place",
                    "location": {
                        "lat": 14.5775706,
                        "lng": 121.0423584
                    },
                    "originalLocation": {
                        "lat": 14.5775499,
                        "lng": 121.04239
                    }
                }
            },
            "arrival": {
                "time": "2022-02-03T19:01:03+08:00",
                "place": {
                    "type": "place",
                    "location": {
                        "lat": 14.5773811,
                        "lng": 121.0426889
                    },
                    "originalLocation": {
                        "lat": 14.5773499,
                        "lng": 121.04274
                    }
                }
            },
            "summary": {
                "duration": 73,
                "length": 380,
                "baseDuration": 65
            },
            "polyline": "BGm635bs767mHiS0MsEkD8L0KgF0FsEoGgF4IoQsdvb8L3IvRnQze3IvHzK3I9ElD",
            "spans": [{
                    "offset": 0,
                    "topologySegmentId": "+here:cm:segment:46864687"
                },
                {
                    "offset": 3,
                    "topologySegmentId": "+here:cm:segment:47392105"
                },
                {
                    "offset": 7,
                    "topologySegmentId": "-here:cm:segment:26196228"
                },
                {
                    "offset": 8,
                    "topologySegmentId": "-here:cm:segment:23767715"
                },
                {
                    "offset": 10,
                    "topologySegmentId": "-here:cm:segment:21101714"
                }
            ],
            "language": "en-us",
            "transport": {
                "mode": "car"
            }
        }],
    }],
}

Upvotes: 0

Views: 731

Answers (2)

user3505695
user3505695

Reputation:

That is correct in routing V8, there is an offset into polyline in maneuver. Offset is the index into the polyline and all coordinates in V8 work this way. spans, actions, they have offset into the route shape which is an array of coordinates. Example: https://demo.routing.ext.here.com/#url=https://router.hereapi.com/v8/routes?apikey=DEFAULT_API_KEY&origin=52.551325,13.351349&destination=52.514255,13.34929&return=polyline,summary,actions,instructions&transportMode=car enter image description here

Upvotes: 0

Gene
Gene

Reputation: 21

As of 2nd day of February 2022, the position paremeter that outputs latitude and longitude in v7 is not supported in v8 under maneuverAttributes. Source

Upvotes: 0

Related Questions