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

can't set searchbox value progamatically

Open luisrudge opened this issue 10 years ago • 11 comments

This lib is insane! Thanks for that!

I'm using this lib with redux and I can't set the value of the SearchBox progamatically. This is a problem whenever the component is umounted and mounted again, since the map element is re-created. Other props like center and zoom are persisted with redux and passed as props. What I want, is to pass the SearchText value as props as well. Do you think that's possible? Here's a gif showing the issue:

gmaps

Thanks again!

luisrudge avatar Feb 03 '16 03:02 luisrudge

The link below provides an answer for how to set the SearchBox value programmatically (the solution even goes so far as describing how you might also automatically fire the search event); it's not a React-ified solution, so your mileage may vary.

(you can probably simplify the approach as you just want to send the value to your data store or retrieve the value from mapStateToProps by tagging the container <div> with the value and then plucking the <div> value after the component renders)...

http://stackoverflow.com/a/24462418

a fiddle:

http://jsfiddle.net/doktormolle/R8XdL/

tedabbott avatar Feb 04 '16 00:02 tedabbott

Maybe that can work, but I'm not messing with google's stuff in my code, only react-google-maps.. I'm opening the issue so we can discuss how to add this behavior to the current lib.

luisrudge avatar Feb 04 '16 00:02 luisrudge

@luisrudge could you take a look at the source code of SearchBox and issue a PR to make it work? I believe it's doable.

tomchentw avatar Feb 20 '16 05:02 tomchentw

We're going to look into this shortly. Thanks for providing the gif.

We're also looking for maintainers. Involve in #266 to help strengthen our community!

tomchentw avatar May 29 '16 08:05 tomchentw

Did anyone work on this feature?

dash1291 avatar Nov 18 '17 11:11 dash1291

Is there any solution to this use case?

ivandevp avatar Feb 16 '18 16:02 ivandevp

@tomchentw can you please let us know when this solution might be available? My use case is i want to clear the search box input value when i do an onClick of a cancel button. I do not have a way to access the searchbox input value to reset it. Please let us know your thoughts and thanks a ton for this library..!!

akhilmr95 avatar Jan 11 '19 05:01 akhilmr95

@akhilmr95 this repo is unmaintained about a year, please look at https://github.com/JustFly1984/react-google-maps-api instead

JustFly1984 avatar Jan 11 '19 08:01 JustFly1984

@JustFly1984 i do not see any example for searching and plotting a marker in your examples. Is this something in your pipeline? or am i looking at the wrong place? i am referring the examples here:- https://github.com/JustFly1984/react-google-maps-api/tree/master/examples/react-google-maps-api-gatsby/src/examples

akhilmr95 avatar Jan 18 '19 11:01 akhilmr95

@akhilmr95 You could try to make an example yourself. Maintainers are welcome

JustFly1984 avatar Jan 19 '19 02:01 JustFly1984

@tomchentw Can you please look into this issue? It would be of great help if we can access the value of the search box. Also it would be very helpful to provide an onSelect which would return the address selected from the dropdown when we search. Please look into this. Thanks..!!

akhilmr95 avatar Jan 22 '19 13:01 akhilmr95