最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - How to move camera to a new marker? - Stack Overflow

programmeradmin4浏览0评论

I installed react-yandex-maps package in my ReactJS project. I am able to place a marker, but I cant move the camera of the map to a marker that was placed on the map. I could not find the method in the documentation. Can someone please share how to do it? Thank you!

    <Map
        className={styles.mapStyle}
        instanceRef={ref => setMapRef(ref)}
        modules={["control.ZoomControl", "control.FullscreenControl"]}
        defaultState={{
            zoom: 12,
            controls: ["zoomControl", "fullscreenControl"],
        }}
    >
        {
            selectedPoint.length === 2 &&
            <Placemark 
                geometry={selectedPoint}
            />
        }
    </Map>

This is part of my code, and the marker changes its position based on the state variable selectedPoint. Marker moves, but not the camera. I have ref of the map and console.log of the ref does not show the methods I need.

发布评论

评论列表(0)

  1. 暂无评论