Встраиваю карты в мобильное приложение. Мне понадобилось сделать управление масштабом карты в виде двух круглых кнопок (+) и (-). Взял пример от Яндекс, слегка изменил и сделал свой zoomControl (код см. ниже). Но вот незадача - при двойном щелчке кнопки увеличиваются вместе с картой. Пробовал навешивать обработчик на dblclick на ZoomControl и на всю карту, пробовал фильтровать события сlick, но все это не помогло.
// Creating a custom layout for the zoom slider.
ZoomLayout = ymaps.templateLayoutFactory.createClass("<div>" +
"<div id='zoom-in' class='button'><img src='mb2capp://plus.png' width='100px' height='100px'></div><br>" +
"<div id='zoom-out' class='button'><img src='mb2capp://minus.png' width='100px' height='100px'></div>" +
"</div>", {
/**
* Redefining methods of the layout, in order to perform
* additional steps when building and clearing the layout.
*/
build: function () {
// Calling the "build" parent method.
ZoomLayout.superclass.build.call(this);
/**
* Binding handler functions to the context and storing references
* to them in order to unsubscribe from the event later.
*/
this.zoomInCallback = ymaps.util.bind(this.zoomIn, this);
this.zoomOutCallback = ymaps.util.bind(this.zoomOut, this);
// Beginning to listen for clicks on the layout buttons.
$('#zoom-in').bind('click', this.zoomInCallback);
$('#zoom-out').bind('click', this.zoomOutCallback);
},
clear: function () {
// Removing click handlers.
$('#zoom-in').unbind('click', this.zoomInCallback);
$('#zoom-out').unbind('click', this.zoomOutCallback);
// Calling the "clear" parent method.
ZoomLayout.superclass.clear.call(this);
},
zoomIn: function () {
var map = this.getData().control.getMap();
map.setZoom(map.getZoom() + 1, {checkZoomRange: true});
},
zoomOut: function () {
var map = this.getData().control.getMap();
map.setZoom(map.getZoom() - 1, {checkZoomRange: true});
}
}),
zoomControl = new ymaps.control.ZoomControl({options: {layout: ZoomLayout}});
myMap.controls.add(zoomControl, { float: 'none', position: {right: '50px', top: '250px'} });