Get waypoints between two points

I tried to develop an iOS application like this .

I need to calculate intermediate locations between two cities or two points. I could not figure out which API was the best. I tried google API. But this does not give a place between two points. Can anyone suggest an API. I need to do it fast.

thanks

+4
source share
1 answer

You need to use this api to get routes between two locations and cities.

when you run this api you get the encoded polyline object in this dictionary

overview_polyline: {
points: "m_qkCknuyLiIgEeAw@gA_A{HgGs@i@i@|@m@jAuCdGa@z@QRy@pBYXa@t@BBf@b@tE`Aa@lJKjA?P"
},

- , ,

NSInteger index = 0, len = encoded.length;
int lat = 0, lng = 0;
while (index < len) {
    int b, shift = 0, result = 0;
    do {
        //            b = encoded.charAt(index++) - 63;
        b = [encoded characterAtIndex:index++] - 63;
        result |= (b & 0x1f) << shift;
        shift += 5;
    } while (b >= 0x20);
    int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
    lat += dlat;
    shift = 0;
    result = 0;
    do {
        b = [encoded characterAtIndex:index++] - 63;
        result |= (b & 0x1f) << shift;
        shift += 5;
    } while (b >= 0x20);
    int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
    lng += dlng;
    CLLocation *loc = [[CLLocation alloc] initWithLatitude:((double) lat / 1E5) longitude:((double) lng / 1E5)];
    [arrLocation addObject:loc];
}
+4

Source: https://habr.com/ru/post/1620474/


All Articles