react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

Allow InfowWindow anchor to be a <Marker/> component

Open uriklar opened this issue 8 years ago • 24 comments

Right now supports only position property

uriklar avatar Dec 01 '18 13:12 uriklar

Hi, I'm trying to make a Circle marker with a InfoWindow popup. Any documentation or example about it? Many thanks in advance

eur2 avatar Mar 01 '19 10:03 eur2

Hi @grdpr, Something like this? https://codesandbox.io/s/2vx96zljk0 You can give the marker a circle icon using the icon property, or even use an actual circle instead

P.S. Any reason you want to use an InfoWindow instead of an OverlayView? InfoWindow gives you some default styles you can't control and also the X close button that closes it without going through react

uriklar avatar Mar 01 '19 12:03 uriklar

Thanks @uriklar! I'll give a try to render a list of markers with this InfoWindow and also with OverlayView to feel the difference. OverlayView isn't include in the API from GoogleMaps right?

eur2 avatar Mar 01 '19 12:03 eur2

Included indeed: https://developers.google.com/maps/documentation/javascript/reference/overlay-view#OverlayView Take note that you don't need to handle the onAdd, onDraw etc... callbacks. We handle them for you.

uriklar avatar Mar 01 '19 12:03 uriklar

Thanks for all this work! I'm struggling by testing many react-google-map-package. Is there any onClick event possible on the wrapper to listen for a click?

eur2 avatar Mar 01 '19 13:03 eur2

Not sure what you mean by "wrapper" but almost every component exposes an onClick event handler

uriklar avatar Mar 01 '19 15:03 uriklar

@uriklar the onClick event handler works well on the map! But I'm still struggling to render multiple markers with InfoWindow. When I open one infoWindow, all infoWindow are opening.

eur2 avatar Mar 04 '19 14:03 eur2

Do you want to share a codesandbox? I wouldn't create multiple info windows. I'd create one info window and pass it the props depending on the selected marker (I.E - the marker's position and any info related to the selected marker you want to show)

urikphytech avatar Mar 04 '19 14:03 urikphytech

here it is: https://codesandbox.io/s/l2jn4xm9yl

eur2 avatar Mar 04 '19 14:03 eur2

@grdpr https://codesandbox.io/s/l2jn4xm9yl returns 404.

michaelsync avatar Mar 19 '19 05:03 michaelsync

how do we pass the anchor Marker object from an onHover? seems like we can only populate some state or store with onLoad

Kiel-H-Byrne avatar Apr 08 '19 02:04 Kiel-H-Byrne

@tdotholla I didn't quite understand what you're asking

uriklar avatar Apr 08 '19 08:04 uriklar

@tdotholla I didn't quite understand what you're asking

No problem. it was explained better by @FredyC here (https://github.com/JustFly1984/react-google-maps-api/issues/18#issuecomment-481849486)

I think also you guys implemented his suggestions or pull requests... so i can hop off of this thread. I didn't realized i may have hijacked it a bit.

Also i don't use "anchor" parameter and my infowindow is nested outside or Marker tags... not sure if that helps but it's working great for me with InfoWindow just having "position" parameter.

Kiel-H-Byrne avatar Apr 11 '19 16:04 Kiel-H-Byrne

published 1.2.3-alpha.1

JustFly1984 avatar Apr 12 '19 16:04 JustFly1984

@tdotholla please test

JustFly1984 avatar Apr 12 '19 19:04 JustFly1984

Is this still open? There are error messages (infoWindow.tsx line 79) that indicate the component is expected to be rendered inside a Marker, but it doesn't look like the code is there to do this yet???

hswope-arcweb avatar Apr 29 '19 17:04 hswope-arcweb

@uriklar please look at this issue, I have no time today

JustFly1984 avatar Apr 30 '19 01:04 JustFly1984

@hswope-arcweb The error message on line 79 is only triggered if there's no anchor or position property defined. There currently is anchor support, but it's not very usable. It requires you to pass in a google Marker object (as opposed to a component which would be a much nicer behaviour)

Instead of using an anchor, i'd go with the approach detailed in this sandbox: https://codesandbox.io/s/x200klrl5w

uriklar avatar May 01 '19 04:05 uriklar

@uriklar Thanks for the reply. That makes sense. I ended up going with an OverlayView for my implementation anyway, which had its own challenges associating it (visually) with a marker. If time allows, I was thinking of adding some functionality to the OverlayView component and putting in a PR. In general, I like this library. Although new, it is tight and clean. Thanks for your work.

hswope avatar May 01 '19 13:05 hswope

@hswope You are welcome!

JustFly1984 avatar May 01 '19 16:05 JustFly1984