Я хочу нарисовать маршруты на карте, соответствующей направлениям JSON, которые я получаю через API Google Directions: http://code.google.com/apis/maps/documentation/directions/ p >
Я выяснил, как извлечь широту и долготу из поля шагов, однако это не очень хорошо сочетается с извилистыми дорогами. Я думаю, что мне нужно, чтобы расшифровать информацию о полилинии, я нашел инструкции Googles о том, как кодировать полилинии: http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html
Я нашел здесь код для Android, а также Javascript при декодировании полилиний, например:
Отображение маршрута с помощью google Directions API - декодирование полилиний
android получить и разобрать Google Directions
Но я не могу найти то же самое для кода Objective-C iPhone, может ли кто-нибудь помочь мне в этом? Я уверен, что смогу сделать это сам, если придется, но он наверняка спасет меня, если он уже будет доступен где-то...
EDIT: ключ здесь может декодировать кодировку base64 на основе символа по символу. Чтобы быть более конкретным, я получаю что-то подобное в JSON от Google, который кодируется с использованием кодировки base64 между прочим:
... "overview_polyline" : {
"points" : "[email protected]@[email protected][email protected]@[email protected][email protected]@aB\\GBMB"
},
...
Примечание. Я должен упомянуть, что этот вопрос относится к API Карт Google v1, гораздо проще сделать это в v2, используя GMSPolyLine polyLineWithPath, как многие ответы ниже расскажут вам (спасибо @cdescours).