D
D
Daniil Vershinin2018-06-16 14:35:00
JavaScript
Daniil Vershinin, 2018-06-16 14:35:00

How to pass an array of coordinates to YandexMaps?

The bottom line is that you need to read the xml file with the gps track and then display it on the map. But at the same time, select certain sections according to the condition (in a different color).
I am getting an array of labels using JQ:

function ajaxGetXML(){

    $.ajax({
        type: "POST", // метод передачи данных
        url: "test.xml", // путь к xml файлу
        dataType: "xml", // тип данных
        // если получили данные из файла
        success: function(data) {
            var html = "";
            // перебираем все теги trkpt
            $(data).find('trkpt').each(function(){
                lat.push($(this).attr('lat'));
                lon.push($(this).attr('lon'));
            });         
            $('#content_div').html(html); // выводим данные
        },
        // если произошла ошибка при получении файла
        error: function(){
            alert('ERROR');
        }
         
    });
}

Further, these arrays are divided into other arrays and must be displayed on the map, for example, using Yandex maps, this can be done using curves..
var myGeoObject = new ymaps.GeoObject({
            // Описываем геометрию геообъекта.
            geometry: {
                // Тип геометрии - "Ломаная линия".
                type: "LineString",
                // Указываем координаты вершин ломаной.
                coordinates: [
                    [55.80, 37.50],
                    [55.70, 37.40]
                ]
            },

how in
coordinates: [
                    [55.80, 37.50],
                    [55.70, 37.40]
                ]

drive these nva js array?
Or, how do you think, how can this be more rationally implemented, not necessarily using the YaK API?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question