Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to make DirectionsRenderer draggable, but it doesn't work. #159

Closed
wildskyf opened this issue Nov 23, 2015 · 6 comments
Closed

I want to make DirectionsRenderer draggable, but it doesn't work. #159

wildskyf opened this issue Nov 23, 2015 · 6 comments

Comments

@wildskyf
Copy link

Hi, Tom Chen, I want to do this, but my direction just stuck. Here is what I did:

render () {
    const {directions} = this.state;
    return (
        <GoogleMapLoader
            containerElement={
                <div
                    {...this.props}
                    style={{
                        margin: "1rem 1.75rem",
                        height: "300px",
                        width: "500px"
                    }}/>
            }
            googleMapElement={
            <GoogleMap
                ref="map"
                defaultZoom={17}
                defaultCenter={{ lat: 25.0432253, lng: 121.53263262 }}>
                {directions ?
                    <DirectionsRenderer
                        directions={directions}
                        draggable={true}    // Draggable is here !!!
                        map={this.refs.map}
                        /> :
                    null
                }
            </GoogleMap>
            }
        />
    );
}

Do you know where is the problem?

thanks :)

@wildskyf wildskyf changed the title Make DirectionsRenderer draggable I want to make DirectionsRenderer draggable, but it doesn't work. Nov 23, 2015
@tomchentw
Copy link
Owner

First, you don't need to set map={this.refs.map} when using react-google-maps.

Second, the draggable is in setOptions, so you'll have to specify it:
https://developers.google.com/maps/documentation/javascript/reference#DirectionsRendererOptions

<DirectionsRenderer
  directions={directions}
  options={{draggable:true}} // or defaultOptions
/> 

See README.md Rule 4: https://github.com/tomchentw/react-google-maps#rule-4

@wildskyf
Copy link
Author

It works!! I couldn't understand Rule 4 before, but now I realize it!
Thank you for your detailed instant reply. :D

@tomchentw
Copy link
Owner

LOL sorry about the poor documentation :( #128

@wildskyf
Copy link
Author

Nope, it's my bad.
I am new to react & My english isn't very good.
Don't beat yourself up. ;)

@tomchentw
Copy link
Owner

Thanks @wi1d5ky ! Let's keep moving forward.

tomchentw added a commit that referenced this issue Nov 24, 2015
@Tjorriemorrie
Copy link

Isn't directions also in the options? Why is that a normal attribute?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants