pointCode
, say LPC1).Code="LPC1"
, here I need to get the coordinates just this item$('#cdek_point_id').change(function() {
var pointCode = $(this).val();
$.ajax({
type: "GET",
url: 'https://integration.cdek.ru/pvzlist.php',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
data : { cityid : 320},
dataType: "xml",
success: function(result) {
var points = result.getElementsByTagName("Pvz");
// result is the xml
console.log(result);
// points to the object with lists of items
console.log(points);
ymaps.ready(init);
function init() {
var myMap = new ymaps.Map("YMapsID", {
// Need to specify the coordinates of the selected point.
// for example, to compare the pointCode from the result and display only
// coordinates from array where Code == pointCode
// (Code is the attribute in the response xml)
center: [52.608782, 39.599346],
zoom: 10
}, {
searchControlProvider: 'yandex#search'
});
for (i=0;i<points.length;i+=1) { Here I have sorted out the items and deduce the map var address="result.getElementsByTagName("Pvz")[i].getAttribute('full address');" phone="result.getElementsByTagName("Pvz")[i].getAttribute('Phone');" worktime="result.getElementsByTagName("Pvz")[i].getAttribute('WorkTime');" info="address" + '<br><b>Phone:</b> ' + phone + '<br><b>Time.</b> ' + workTime;
var site = result.getElementsByTagName("Pvz")[i].getAttribute('Site');
var lat = parseFloat(result.getElementsByTagName("Pvz")[i].getAttribute('coordY'));
var lon = parseFloat(result.getElementsByTagName("Pvz")[i].getAttribute('coordX'));
// Create a geo with geometry type "Point".
var myGeoObject = new ymaps.GeoObject({
// Description of the geometry.
geometry: {
type: "Point",
coordinates: [lat, lon]
},
// Properties.
properties: {
balloonContent: info,
hintContent: info
}
}, {
// Options.
preset: 'islands#blueIcon'
});
myMap.geoObjects.add(myGeoObject);
}
}
}
});
});</points.length;i+=1)>
Find more questions by tags jQueryJavaScript