A custom label is drawn on the map, the position of which is calculated from the coordinates of the label to which it is attached.

Drawing example: https://jsfiddle.net/d1eL2h5m/21/

The problem is that in the process of scaling from the beginning of the event to the end, a function is started that calculates the label's position, but if at the end of scaling and at the beginning the top and left pixels of the position are calculated correctly, then the process itself produces very large values ​​and the label flies in the side of the card. Dragging a map with a mouse also calculates the position of the label, but with such an event, everything is correct and the label always remains under the label.

In the process of scaling the position is calculated as follows:

_reposzoom: function() { global = YMYmap.options.get('projection').toGlobalPixels([55.752, 37.627], YMYmap.getZoom()); var position = YMYmap.converter.globalToPage(global); offset = YMYmap.container.getOffset(); this.options.set('position',{ top: position[1] - offset[1], left: position[0] - offset[0] - parseInt(this._$content.parent().outerWidth())/2}); this._$content.parent().css({ left : position[0] - offset[0] - parseInt(this._$content.parent().outerWidth())/2 + 'px', top : position[1] - offset[1] + 'px' }); } 

How to ensure that the label does not fly to the side of the map during scaling and remains under the label?

  • And why just do not make your own label layout immediately with the label, so that it scales and is positioned by means of API? - Reni
  • and what are the options using the API, so that you have your own design and labels, and a label, and so that you can change the text in the label, or hide the entire label (only the label)? - alex37
  • You can make your label template with / without label and programmatically change the content in the label and show / hide it. The layout will need to be programmed, and all the behavior will already make the API itself. An example of custom layouts: tech.yandex.ru/maps/jsbox/2.1/placemark_shape - Reni

0