javascript - Not able to render the infoWindow in react-google-maps - Stack Overflow

I was trying to add an InfoWindow to the mid point of a polyline. This is my code for displaying the in

I was trying to add an InfoWindow to the mid point of a polyline.

This is my code for displaying the infoWindow.

<InfoWindow
   position={this.state.windowPosition}
   onCloseclick={this.toggleInfoWindow}
   options={{pixelOffset: new google.maps.Size(0,-30)}}
>
       <p>iggd</p>
</InfoWindow>

windowPosition here is the lat and lng of the midpoint of the polyline. When I try to run this I am getting an error saying that You must provide either an anchor (typically render it inside a <Marker>) or a position props for <InfoWindow>. But the owner of the repo said that (link's here) we can render an infoWindow where ever we want if we pass a position as props which I am doing.

Any help is appreciated.

I was trying to add an InfoWindow to the mid point of a polyline.

This is my code for displaying the infoWindow.

<InfoWindow
   position={this.state.windowPosition}
   onCloseclick={this.toggleInfoWindow}
   options={{pixelOffset: new google.maps.Size(0,-30)}}
>
       <p>iggd</p>
</InfoWindow>

windowPosition here is the lat and lng of the midpoint of the polyline. When I try to run this I am getting an error saying that You must provide either an anchor (typically render it inside a <Marker>) or a position props for <InfoWindow>. But the owner of the repo said that (link's here) we can render an infoWindow where ever we want if we pass a position as props which I am doing.

Any help is appreciated.

Share Improve this question asked Feb 10, 2018 at 9:52 vineethvineeth 431 silver badge4 bronze badges 1
  • What value do you get when you console.log(this.state.windowPosition) right before your InfoWindow ponent? – Iavor Commented Feb 10, 2018 at 14:17
Add a ment  | 

1 Answer 1

Reset to default 4

You could do something like this:

            {this.state.position && 
                 <InfoWindow position={this.state.position}>
                     <h1>My InfoWindow</h1>
                 </InfoWindow>
             }

This topic is discussed here.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745078327a4609969.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信