window.map.on('draw:created', function (e) {
var type = e.layerType,
layer = e.layer;
if (type === 'marker') {
// Do marker specific actions
}
var myvar = "foo"; // вот переменная
var get_myvar;
var set_myvar;
window.map.on('draw:created', function (e) {
var type = e.layerType,
layer = e.layer;
if (type === 'marker') {
// Do marker specific actions
}
var myvar = "foo"; // вот переменная
get_myvar = function(){
return myvar;
}
set_myvar = function(val){
myvar = val;
}
});
console.log( "myvar="+ get_myvar() );
set_myvar("new_value");
console.log( "myvar="+ get_myvar() );
var myvar;
window.map.on('draw:created', function (e) {
var type = e.layerType,
layer = e.layer;
if (type === 'marker') {
// Do marker specific actions
}
myvar = "foo"; // вот переменная
var obj = (function(){
var myvar;
window.map.on('draw:created', function (e) {
myvar = "foo";
});
return {
getVar: function(){
return myvar;
}
};
})();
window.map.trigger('draw:created');
console.log(obj.getVar());