JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://api-maps.yandex.ru/2.0-stable/?load=package.full&lang=ru-RU"></script>
<a id="add-user-point" href="#">Добвить точку</a>
<div id="map"></div>
CSS
#map {
height:500px;
width:500px;
}
JavaScript
var map;
ymaps.ready(function() {
map = new ymaps.Map("map", {
center: [55.753585, 37.620905],
zoom: 15
});
map.controls.add("mapTools").add("zoomControl");
});
$(document).ready(function(){
$('a#add-user-point').live('click', function(e) {
e.preventDefault();
if (map) {
var coords = map.getCenter();
var myPlacemarkLayout = ymaps.templateLayoutFactory.createClass(
'<div class="userPlacemarkElement">' +
'<div class="userPlacemarkElementWrap">' +
'<input name="description"/>' +
'</div>' +
'</div>'
, {
build: function() {
this.constructor.superclass.build.call(this);
var self = this, parent = this.getParentElement(), elem = $(parent).find('.iconLayoutElement');
this._element = $('.userPlacemarkElement', this.getParentElement());
var coords = this.getClientBounds();
var offset = [-1 * (parseInt(coords[1][0])) / 2, -1 * (parseInt(coords[1][1])) - 15];
elem.css({
'position': 'relative',
'marginLeft': offset[0] + 'px',
'marginTop': offset[1] + 'px'
});
},
getClientBounds: function() {
var position = this._element.position();
return [
[position.left, position.top], [
position.left + this._element[0].offsetWidth,
position.top + this._element[0].offsetHeight
]
];
}
});
ymaps.layout.storage.add('my#userPlacemark', myPlacemarkLayout);
var pm = new ymaps.Placemark(coords, {}, {
iconLayout: 'my#userPlacemark'
,draggable:...