MicheleBertoli / react-gmaps

A Google Maps component for React.js

Home Page:http://react-gmaps.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help: Adding SearchBox for places..

monski opened this issue · comments

Hello can you help me add a searchbox on gmaps?

i did this on:

onMapCreated(map) {
var input = document.getElementById( document.getElementById('searchmap') );
var searchBox = new google.maps.places.SearchBox(input);

but getting error "Uncaught TypeError: Cannot read property 'SearchBox' of undefine"

thanks in advance

Sorry for the post... i figured it out already, adding key in params of the component...

thanks

Are you able to post an example of your working code? I cant get a searchbox happening at all.

Hi,

get the sample code here:
https://developers.google.com/maps/documentation/javascript/examples/places-searchbox

then on React Gmaps

const Maps = React.createClass({ Gmaps: {}, onMapCreated(map) { let input = this.refs.searchmap // this is my textbox ref let searchBox = new google.maps.places.SearchBox(input); // and some of the code from the link
then add a params in Gmaps component
params={{v: '3.exp', key: "YOUR_API_KEY, libraries: 'places'}}

thanks!