Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Как воспользоваться методом findOrganization ? #318

Open
AVeselov95 opened this issue Jan 28, 2022 · 1 comment
Labels
question yandex.maps api Issues or questions related to Yandex.Maps, not to the library

Comments

@AVeselov95
Copy link

Беру YMaps провайдер и через withYMaps получаю ymaps (Yandex.Maps API object)

но при попытке вызвать ymaps.findOrganization получаю ошибку ymaps.findOrganization is not a function

пример
https://codesandbox.io/s/eager-brahmagupta-p5crh?file=/src/App.js

@mmarkelov mmarkelov added question yandex.maps api Issues or questions related to Yandex.Maps, not to the library labels Jan 28, 2022
@mmarkelov
Copy link
Contributor

mmarkelov commented Jan 28, 2022

@AVeselov95 Я не знаю какой частью модуля является этот метод. Работает с подключением полной библиотеки:

import "./styles.css";
import { YMaps, withYMaps } from "react-yandex-maps";

const Button = ({ ymaps }) => {
  const onClick = async () => {
    if (ymaps) {
      const data = await ymaps.findOrganization("1671141286");
      console.log(data);
    }
  };

  return <button onClick={onClick}> get </button>;
};

const ButtonWithYMap = withYMaps(Button, true);

export default function App() {
  return (
    <>
      <YMaps
        query={{
          apikey: "API_KEY",
          lang: "en_RU",
          load: "package.full"
        }}
      >
        <ButtonWithYMap />
      </YMaps>
    </>
  );
}

Также без ключа разработчика скорее всего не заработает

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question yandex.maps api Issues or questions related to Yandex.Maps, not to the library
Projects
None yet
Development

No branches or pull requests

2 participants