Accessing Leaflet maps from custom module Trying to add to Leaflet map marker from the custom module. Leaflet map created with IP Geolocation Views &amp; Maps module. I try to connect to the map as described here http://dripl.nl/blog/taming-leaflet-maps-drupal
The message alert appears with the coordinates, but the map does not increase the zoom. What could be the reason?

I also tried to replace the string myMap = lMap; with var myMap = Drupal.settings.leaflet [0] .lMap; not help.

test_module.module

function test_module_form_article_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    $form['field_photo']['#element_validate'][] = 'test_module_validate_function';
}

function test_module_validate_function($element, &amp;$form, &amp;$form_state){
    $marker = [49.055688666667,34.338167222222];
    test_module_add_marker($marker);

}

function test_module_add_marker($marker) {
    drupal_add_js(drupal_get_path('module', 'test_module').'/test_module.js'); 
    drupal_add_js(array('test_module' =&gt; array('marker' =&gt; $marker)), array('type' =&gt; 'setting'));
}


test_module.js

(function($) {
  $(document).bind('leaflet.map', function(e, map, lMap){
    myMap = lMap;
  });

    Drupal.behaviors.test_module = {
        attach: function (context, settings) {
            latlon = settings.test_module.marker;
            alert(latlon);
            myMap.setView(latlon, 14);  
        }
    };

})(jQuery);
I managed to solve the problem in the following way, I hope it save someone time:

(function($) {

var lMap = Drupal.settings.leaflet[0].lMap;

    Drupal.behaviors.test_module = {
        attach: function (context, settings) {
            latlon = settings.test_module.marker;
            //alert(latlon);
            lMap.setView(latlon, 14);
        }
    };

})(jQuery);