Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Infobox In my code has error? #451

Closed
pebf opened this issue Mar 26, 2017 · 1 comment
Closed

Why Infobox In my code has error? #451

pebf opened this issue Mar 26, 2017 · 1 comment

Comments

@pebf
Copy link

pebf commented Mar 26, 2017

React-google-maps is nice library for my app, but I have trouble with using 'InfoBox'.

import { withGoogleMap, GoogleMap, Marker, InfoWindow } from 'react-google-maps'; 
import InfoBox from 'react-google-maps/lib/addons/InfoBox';

const GoogleMapWrapper = withGoogleMap((props) => (
  <GoogleMap
     ref={ props.onMapLoad }
     zoom={ props.zoom || 13 }
     center={ props.center }
     onClick={ props.onMapClick }
     onDragEnd={ props.onMapDragEnd }
     onZoomChanged={ props.onZoomChanged }
     options={{      
       streetViewControl: false,
       disableDefaultUI: true
     }} >      
      <Marker
         position={props.center}
         key={props.placeKey}
         defaultAnimation={2}
         onRightClick={() => props.onMarkerRightClick()} 
         icon={ MARKER_ICON_INFO } >        
         <InfoBox 
            position={ props.center }
            options={{
              position: props.center,       
              content: '<div>' + props.placeKey + '</div>',
              closeBoxURL: "",
              maxWidth: 200,
              boxClass: 'txt_location',
              disableDefaultUI: false,
              visible: true            
            }}>
            <div className="temp"></div>
          </InfoBox>  
      </Marker>
  </GoogleMap>
));

const MapCellSearchInput = React.createClass({
  render() {
<div className="map_box">
  <GoogleMapWrapper
     containerElement={ <div style={{ width: '430px', height: '432px' }} />  }
     mapElement={ <div style={{ width: '430px', height: '432px' }} /> }  
     onMapLoad={ (gmap) => {this.gmap = gmap;} }
     onMapClick={this.onMapClick}
     onMapDragEnd={ this.onMapDragEnd }
     onZoomChanged={ this.onZoomChanged }
     center={ mapCoordinate }
     placeKey={ placeKey } 
     zoom={ zoom } />
</div> 
  }
})

It shows 'Uncaught Error: _registerComponent(...): Target container is not a DOM element' error. and when I remove InfoBox's child, like

<InfoBox 
  position={ props.center }
  options={{
    position: props.center,       
    content: '<div>' + props.placeKey + '</div>',
    closeBoxURL: "",
    maxWidth: 200,
    boxClass: 'txt_location',
    disableDefaultUI: false,
    visible: true            
    }}>          
</InfoBox>

It shows 'Uncaught Error: React.Children.only expected to receive a single React element child.', too. How can I solve this problem?

@tomchentw
Copy link
Owner

Please refer to Getting Help section in the README (or #469).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants