F
F
fronter-up2017-10-06 18:11:54
JavaScript
fronter-up, 2017-10-06 18:11:54

SearchBox google maps in React component, how?

Good afternoon! Please tell me how to display searchBox in react google maps?
Already tried everything, gives an error - Cannot read property 'SearchBox' of undefined I'm
using the google-map-react plugin.
At least tell me where to look ...
I will be very grateful!
Component code:

import React, {Component} from 'react';

export default class SearchBox extends Component {
    constructor(props) {
        super(props);
        this.changeInp = this.changeInp.bind(this)
    }

    changeInp = (e, r) => {
        let searchBox = google.maps.places.SearchBox(this.myTextInput);
        console.log(searchBox)
        console.log(google.maps)
        let places = searchBox.getPlaces();

    }

    render() {
        return (
            <input id="pac-input" className="controls" onChange={this.changeInp} ref={(ref) => this.myTextInput = ref}  type="text"
                   placeholder="Search Box"/>

        )
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-10-06
@AXP-dev

Here - https://tomchentw.github.io/react-google-maps/#!/S...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question