gribnoysup / react-yandex-maps

Yandex Maps API bindings for React
MIT License
329 stars 116 forks source link

Не работает автоматическое центрирование и зум #311

Closed ghost closed 3 years ago

ghost commented 3 years ago

Согласно докам, если не задана центральная точка и зум, то они выставляются автоматически по крайним объектам. https://yandex.ru/dev/maps/staticapi/doc/1.x/dg/concepts/map_auto_position.html

Но если в компоненте не передавать defaultState, то получаю

full-ffb813a29f30feadb63b5654242d042b7b6a91aa.js:1015 Uncaught TypeError: Cannot read property '1' of undefined
    at Object.geoToMercator (VM3354 full-ffb813a29f30feadb63b5654242d042b7b6a91aa.js:1015)
    at Object.toGlobalPixels (VM3354 full-ffb813a29f30feadb63b5654242d042b7b6a91aa.js:1013)
    at new J (VM3354 full-ffb813a29f30feadb63b5654242d042b7b6a91aa.js:621)
    at Function.n.mountObject (Map.js:70)
    at n.componentDidMount (Map.js:22)
    at commitLifeCycles (react-dom.development.js:20663)
    at commitLayoutEffects (react-dom.development.js:23426)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
    at invokeGuardedCallback (react-dom.development.js:4056)
    at commitRootImpl (react-dom.development.js:23151)
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at commitRoot (react-dom.development.js:22990)
    at performSyncWorkOnRoot (react-dom.development.js:22329)
    at react-dom.development.js:11327
    at unstable_runWithPriority (scheduler.development.js:468)
    at runWithPriority$1 (react-dom.development.js:11276)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
    at flushSyncCallbackQueue (react-dom.development.js:11309)
    at scheduleUpdateOnFiber (react-dom.development.js:21893)
    at Object.enqueueSetState (react-dom.development.js:12467)
    at s.push../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:365)
    at withYMaps.js:25

Реально починить? Спасибо

mmarkelov commented 3 years ago

@protek-vrn вы смотрите документацию по статическим картам 1ой версии. Примеры актуальной инициализации можете посмотреть здесь