A
A
Anumik2016-07-19 10:27:47
JavaScript
Anumik, 2016-07-19 10:27:47

Why is data from Bitrix IB not displayed when displayed in Yandex.Map?

Good afternoon!
I started programming recently, so sometimes I can blunt it, but usually it turns out to figure it out, but now I ran into a problem
. The site has Bitrix, it is necessary to transfer the points specified by the elements of the info block to Yandex.maps.
The result is the following code:

<script type="text/javascript">
ymaps.ready(function () {
    var myMap = new ymaps.Map('map', {
            center: [48.479862298148, 135.07525863163],
            zoom: 9
        }, {
            searchControlProvider: 'yandex#search'
        }),
        <?foreach($arResult["ITEMS"] as $arItem):?>//цикл на добавление точек
            <?
                $arMark = explode(",",$arItem["PROPERTIES"]["POINT"]["VALUE"]);
                $centerMap[0] += $arMark[0];
                $centerMap[1] += $arMark[1];
                $countMark++; //получаем координаты
            ?>
        myPlacemark = new ymaps.Placemark([<?=$arMark[0]?>, <?=$arMark[1]?>], {}, {
            // Опции.
            // Необходимо указать данный тип макета.
            iconLayout: 'default#image',
            // Своё изображение иконки метки.
            iconImageHref: 'images/map-target.png',
            // Размеры метки.
            iconImageSize: [30, 42],
            // Смещение левого верхнего угла иконки относительно
            // её "ножки" (точки привязки).
            iconImageOffset: [-3, -42]
        });
        <?endforeach;?>

    myMap.geoObjects.add(myPlacemark);
});
</script>

I checked it on the local without the Bitrix code, I set the point myself, it worked fine, but it didn’t
work here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anumik, 2016-07-19
@Anumik

Need to add a cluster

<script type="text/javascript">
ymaps.ready(init);
    var myMap;
    var clusterer;
    var clustererF;

    var balunIcon = {
            iconLayout: 'default#image',
            iconImageHref: '<?=SITE_TEMPLATE_PATH?>/img/map-target.png',
            iconImageSize: [26, 36],
            iconImageOffset: [-13, -18]};
function init(){
   	
   	myMap = new ymaps.Map('map', {
            center: [48.479862298148, 135.07525863163],
            zoom: 9
        });
        clusterer = new ymaps.Clusterer({
            preset: 'islands#invertedRedClusterIcons',
        });

        <?foreach($arResult["ITEMS"] as $arItem):?>//цикл на добавление точек
            <?
                $arMark = explode(",",$arItem["PROPERTIES"]["POINT"]["VALUE"]);
                $centerMap[0] += $arMark[0];
                $centerMap[1] += $arMark[1];
                $countMark++; //получаем координаты
            ?>
        myPlacemark = new ymaps.Placemark([<?=$arMark[0]?>, <?=$arMark[1]?>], {}, balunIcon);
        	<?
        $thisMark = $arMark;
      ?>
      clusterer.add(myPlacemark);
        <?endforeach;?>
       
myMap.geoObjects.add(clusterer);
}
</script>

As a result, it worked and correctly displays an array of points

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question