Answer the question
In order to leave comments, you need to log in
How to properly organize js code?
Good afternoon, there is a task to write a script that would collect data after filtering objects from the page and show them as points on the map, + would display some brief information in the balloon on the map, I managed to collect all the addresses, geocode them and display them on the Yandex map in the form tags, here is my code
function init() {
var big_Map = false;
var myMap = new ymaps.Map('map', {
center: [55.666666, 37.788628],
zoom: 9,
behaviors: ['default', 'scrollZoom']
});
var massive_adres = $('.coords'); // массив адресов которые в последствии геокодируются и выводятся на карту
var pagetitle = $('.pagetitle'); //массив заголовков
massive_adres.each(function(i){
var objects = ymaps.geoQuery(ymaps.geocode($(this).text()))
.setOptions({
iconLayout: 'default#image',
iconImageHref: 'main/red_marker.png',
iconImageSize: [20, 35],
iconImageOffset: [-3, -42]
})
.setProperties({
balloonContentHeader:'Тест ',
balloonContentBody: 'Тест'
})
.addToMap(myMap);
});
Answer the question
In order to leave comments, you need to log in
data-* attributes?
var objects = ymaps.geoQuery(ymaps.geocode($(this).text()))
.setOptions({
iconLayout: 'default#image',
iconImageHref: 'main/red_marker.png',
iconImageSize: [20, 35],
iconImageOffset: [-3, -42]
})
.setProperties({
balloonContentHeader:$(this).data('title'),
balloonContentBody: $(this).data('description')
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question