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

Allow React component as InfoWindow content #25

Closed
sslash opened this issue Mar 31, 2015 · 13 comments
Closed

Allow React component as InfoWindow content #25

sslash opened this issue Mar 31, 2015 · 13 comments

Comments

@sslash
Copy link

sslash commented Mar 31, 2015

It seems that the content in the InfoWindow has to be a String.
However it would be nice to allow more complex UI's here, like a React component as the content.

@tomchentw
Copy link
Owner

Kind of interesting. What's your expected API ?

@tomchentw
Copy link
Owner

Since #32 is landed, currently the InfoWindow API would look like this:
<InfoWindow title="Blabla" onClick={this.handleClick} />

Combined with marker:

<Marker lat={lat} lng={lng}>
  <InfoWindow title="Blabla" onClick={this.handleClick}>
</Marker>

Proposed API for InfoWindow with React component:

<InfoWindow title="Blabla" onClick={this.handleClick}>
  <MyFancyReactComponent>
    <ItShouldAlsoSupportDiffAlgorithmHere />
  </MyFancyReactComponent>
</InfoWindow>

Is this what you want?

@wuct
Copy link
Collaborator

wuct commented May 19, 2015

👍 This API is exactly what I want. But a content of InfoWindow is not in a react shadow DOMs tree, how will you implement this?

@metalmatze
Copy link

This would be exactly what I need. It's crucial for my application!

@tomchentw
Copy link
Owner

This can be implement by the following:

  1. Create a detached DOM using document.createElement
  2. Render the passed in child using React.render(React.Children.only(props.children), detachedDOM)
  3. Pass the detachedDOM into InfoWindow({content: detachedDOM})

What do you guys think?

@wuct
Copy link
Collaborator

wuct commented May 29, 2015

After passing the detachDOM to a InfoWindow, a InfoWindow will call setOptions to set the content internally. So the content of InfoWindow will remount into GoogleMaps DOM tree every time when the InfoWindow is update and won't utilize React diff right?

@wuct wuct closed this as completed May 29, 2015
@wuct wuct reopened this May 29, 2015
@tomchentw
Copy link
Owner

No. As long as the detachedDOM is the same instance, React will recognize it.

@metalmatze
Copy link

I know it's impolite to ask if anyone has implemented this feature, but I want to do it anyway since I would need this feature. Is there any progress? I'm just building my first app with react and I'm not quite sure if I could implement this feature myself. Sorry.

@tomchentw
Copy link
Owner

Released v2.0.0 and v2.0.1.

@ashishchoudhary12
Copy link

how to hide infow window close buttom???

1 similar comment
@ashishchoudhary12
Copy link

how to hide infow window close buttom???

@sriniss13
Copy link

sriniss13 commented Sep 18, 2017

how to customize info window i can't change default style

@umair-khanzada
Copy link

what about the Marker, can we pass jsx element against marker's icon props ?

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

7 participants