0

Внешний вид балуна не изменяется,помогите найти ошибку в коде

import React, {Component} from 'react';

import {Map, Placemark, YMaps} from 'react-yandex-maps';

function createBalloonLayout(ymaps) {
  const BalloonLayout = ymaps.templateLayoutFactory.createClass(
    '<div>new balloon</div>', {
    });
  return BalloonLayout
}


class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      balloonContent: ''
    }
}

  handleApiAvaliable(ymaps) {
    let balloonContent = createBalloonLayout(ymaps);
    this.setState({balloonContent: balloonContent});
  }


  render() {

    return (
      <YMaps
        onApiAvaliable={(ymaps) => this.handleApiAvaliable(ymaps)}
      >
        <Map
          state={{
            center: [0, 0],
            zoom: 3,
            controls: []
          }}
        >
          <Placemark
            geometry={{
              coordinates: [55.751574, 37.573856]
            }}
            properties={{
              hintContent: 'Собственный значок метки',
              balloonContentLayout: this.state.balloonContent
            }}
          />
        </Map>
      </YMaps>
    );
  }
}

export default App;
1

1 ответ 1

1

balloonContentLayout должен быть не в properties , а в options.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.