1

I created a component in react, I want a separate searchbox not embedded in the map itself. I have been looking for tutorial to do this but no luck and also I found the google-maps-react documentation a bit confusing because it utilizes a HOC, compose, to simplify the map.

    const Map = withScriptjs(withGoogleMap(props => {
  return (
      <div className="map-wrap">
        <div className="map-searchbox"><input placeholder="Enter Address" /></div>
        <div className="map">
          <GoogleMap
            defaultZoom={14}
            center={{lat: 42.3601, lng: -71.0589}}
          />
        </div>
      </div>
    )
  }
))

2 Answers 2

1

Just put a style on the containerElement.

<GoogleMap
  defaultZoom={14}
  center={{lat: 42.3601, lng: -71.0589}}
  containerElement={<div style={{height:`500px`,width:`50%`,display:'flex',flexDirection:'column-reverse' }} />}
/>
Sign up to request clarification or add additional context in comments.

Comments

1

If I got your question right, you're talking about searchBox for google Places. For that I made a codesandbox, you just need to add your API key (enable Places API on that key) then It works like a charm. codesandbox: https://codesandbox.io/s/qqzm67ykmq

Feel free to ask any questions.

1 Comment

This is the best answer I've seen to the numerous issues with Autocomplete not handling unit numbers well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.