R
R
run1822017-07-01 13:09:19
JavaScript
run182, 2017-07-01 13:09:19

How to change the display of the Yandex.Maps position on click?

The page has a Bitrix component with a Yandex map. It is necessary to transfer other coordinates to the map by clicking on the button and display them. How can this be done with the API?
I started with this, then I don’t know how to do it right. Please help.

$(document).on('change','#himki',function(){

});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kovalsky, 2017-07-03
@lazalu68

In general, usually links to map objects are still saved so that they can be used, like in your case. But if they are not there, then you can try to decorate the constructor and store these references, for example, in the target element object, something like this:

ymaps.ready(function() {
    const old_Map = ymaps.Map;
    
    ymaps.Map = function() {
        var args = Array.prototype.slice.call(arguments);
        
        args.unshift(0);

        var obj = new (Function.prototype.bind.apply(old_Map, args));

        document.getElementById(args[1]).yaMap = obj;
        return obj;
    }
});

Then you can refer to the map object like this: Here is an example where ymaps.Map is decorated, a map object is created, after which we refer to it and center the map on some other point as an example. The decorator must be executed strictly immediately after loading the Yandex Maps API script and, first of all, on the ready event for ymaps .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question