M
M
mister_pibody2015-10-18 16:26:13
JavaScript
mister_pibody, 2015-10-18 16:26:13

How to resolve the conflict between Yandex maps and jQuery scripts?

Hello!

I made a sliding menu in Jquery:

$(document).ready(function(){
    $('#menu > li'){
        .hide()
        .click(function(e){
        e.stopPropagation();
    }
}
});
$('#menu > li').toggle(function(){
    $(this).find('ul').slideDown();
    }, function(){
        $(this).find('ul').slideUp();
    });

});


There was a block with a map of the place. I had to change Google maps to Yandex maps, after which the menu folded into a narrow strip and after a little shamanism it still opened, but now when you open the page, the menu is automatically displayed expanded and does not collapse when pressed. FancyBox has stopped working too - the page doesn't open inside a page. How can this be fixed?

Map codes

src=" yandex.st/jquery/2.1.1/jquery.min.js " type="text/javascript">
src=" api-maps.yandex.ru/2.1/?lang=ru_RU " type=" text/javascript">
src=" api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU " type="text/javascript">

var myMap;
  ymaps.ready(init); // Ожидание загрузки API с сервера Яндекса
  function init () {
    var myMap = new ymaps.Map('map', {
            center: [5,12],
            zoom: 12,
            
        }, {


            searchControlProvider: 'yandex#search'
        }),

    

    // Создаем геообъект с типом геометрии "Точка".
        myGeoObject = new ymaps.GeoObject({
            // Описание геометрии.
            geometry: {
                type: "Point",
                coordinates: [15,94.14841]
            },
            // Свойства.
            properties: {
                // Контент метки.
                
               
            }
        }, {
            // Опции.
            // Иконка метки будет растягиваться под размер ее содержимого.
            preset: 'islands#blackStretchyIcon',
            // Метку можно перемещать.
            draggable: true
        });



        myMap.controls.add('smallZoomControl');
        myMap.controls.add('typeSelector');

    myMap.geoObjects
        .add(myGeoObject)
        
       
        
        
        
        
        .add(new ymaps.Placemark([58, 32], {
            
            hintContent: 'Проспект Энгельса'
        }, {
            preset: 'islands#circleIcon',
            iconColor: '#4d7198'
        }))
        .add(new ymaps.Placemark([12,49], {
            hintContent: 'Третья улица Строителей'
        }, {
            preset: 'islands#circleDotIcon',
            iconColor: '#1faee9'
        }));
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mister_pibodi, 2015-10-18
@mister_pibody

I eliminated some of the errors from the consoles - one of them was very interesting, it was necessary to disable the adblock)
In general, the problem is solved - everything turned out, as usual, much easier. All you had to do was swap

<script src="http://yandex.st/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
        <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
        <script src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU" type="text/javascript"></script>
       <script src="js/jquery-1.6.3.min.js"></script>
     

       <link href="fancybox/jquery.fancybox-1.3.4.css" rel="stylesheet">
        <script src="fancybox/jquery.fancybox-1.3.4.min.js"></script>

Before that, I rearranged the scripts that I posted above and poked around in the function code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question