Giter Site home page Giter Site logo

地图mapStyle问题 about react-bmap HOT 5 CLOSED

Lpbzzz avatar Lpbzzz commented on June 15, 2024
地图mapStyle问题

from react-bmap.

Comments (5)

Junior2Ran avatar Junior2Ran commented on June 15, 2024

能否提供更加详细的信息?现在没法判断定位问题都原因

from react-bmap.

Lpbzzz avatar Lpbzzz commented on June 15, 2024

虽然现在没这样的需求,但是还是想问一下,想达成这样的功能:把mapstyle存在state里,当setstate({mapstyle:任意的style}),地图的样式随之改变

from react-bmap.

Junior2Ran avatar Junior2Ran commented on June 15, 2024

可以,写个changeMapStyle方法

changeMapStyle(style) {
    this.setState({
        style: style
    });
    this.props.map.setMapStyle({style: style});
}

from react-bmap.

Lpbzzz avatar Lpbzzz commented on June 15, 2024

不好意思。。setMapStyle 这是个react-bmap里的API吗?this.props.map指的是
_20181220115926这个吗?

from react-bmap.

Junior2Ran avatar Junior2Ran commented on June 15, 2024

1.setMapStyle是百度地图原生的jsapi,所以要获取到原生js的map实例化对象。react-bmap也将这个map对象放到了每个子组件的props里

return React.Children.map(children, child => {
    if (!child) {
        return;
    }
    if (typeof child.type === 'string') {
        return child;
    } else {
        return React.cloneElement(child, {
            map: this.map
        });
    }
})

2.是的

from react-bmap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.