react-google-maps
Advanced tools
Changelog
7.1.0 (2017-07-06)
<a name="7.0.0"></a>
Changelog
7.0.0 (2017-04-21)
Before:
import { HeatmapLayer } from "react-google-maps"
After:
import HeatmapLayer from "react-google-maps/lib/visualization/HeatmapLayer"
For react < 15.5.0, use react-google-maps < 7.0.0 instead.
<a name="6.3.0"></a>
Changelog
6.0.1 (2016-10-14)
<a name="6.0.0"></a>
Changelog
6.0.0 (2016-10-04)
googleMapURL
with scriptjs
(14d9273)google.maps.Map
instance (f61724c)Before:
<InfoBox
onCloseclick={_.noop}
onDomready={_.noop}
onZindexChanged={_.noop}
/>
After:
<InfoBox
onCloseClick={_.noop}
onDomReady={_.noop}
onZIndexChanged={_.noop}
/>
react-google-maps
components inside withGoogleMap
HOC.Before:
// v5.0.0
<GoogleMapLoader
containerElement={
<div
{...this.props}
style={{
height: "100%",
}}
/>
}
googleMapElement={
<GoogleMap
ref={(map) => console.log(map)}
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={::this.handleMapClick}>
{this.state.markers.map((marker, index) => {
return (
<Marker
{...marker}
onRightclick={this.handleMarkerRightclick.bind(this, index)} />
);
})}
</GoogleMap>
}
/>
// or v4.0.0
<GoogleMap containerProps={{
...this.props,
style: {
height: "100%",
},
}}
ref="map"
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={::this.handleMapClick}>
{this.state.markers.map((marker, index) => {
return (
<Marker
{...marker}
onRightclick={this.handleMarkerRightclick.bind(this, index)} />
);
})}
</GoogleMap>
After:
// Wrap all `react-google-maps` components with `withGoogleMap` HOC
// and name it GettingStartedGoogleMap
const GettingStartedGoogleMap = withGoogleMap(props => (
<GoogleMap
ref={props.onMapLoad}
defaultZoom={3}
defaultCenter={{ lat: -25.363882, lng: 131.044922 }}
onClick={props.onMapClick}
>
{props.markers.map((marker, index) => (
<Marker
{...marker}
onRightClick={() => props.onMarkerRightClick(index)}
/>
))}
</GoogleMap>
));
// Then, render it:
render(
<GettingStartedGoogleMap
containerElement={
<div style={{ height: `100%` }} />
}
mapElement={
<div style={{ height: `100%` }} />
}
onMapLoad={_.noop}
onMapClick={_.noop}
markers={markers}
onMarkerRightClick={_.noop}
/>,
document.getElementById('root')
);
inputProps
.This will get passed in directly into the underlying <input>
component. You can also override it with inputStyle
, inputClassName
and inputPlaceholder
.
Before:
<SearchBox
placeholder="Customized your placeholder"
style={INPUT_STYLE}
/>
After:
<SearchBox
inputPlaceholder="Customized your placeholder"
inputStyle={INPUT_STYLE}
/>
Before:
<DrawingManager
onCirclecomplete={_.noop}
onOverlaycomplete={_.noop}
/>
After:
<DrawingManager
onCircleComplete={_.noop}
onOverlayComplete={_.noop}
/>
OverlayView
can no longer be rendered under MarkerClusterer
Before:
<InfoWindow
onCloseclick={_.noop}
onDomready={_.noop}
onZindexChanged={_.noop}
/>
After:
<InfoWindow
onCloseClick={_.noop}
onDomReady={_.noop}
onZIndexChanged={_.noop}
/>
Before:
<MarkerClusterer
onClusteringbegin={_.noop}
onMouseout={_.noop}
/>
After:
<MarkerClusterer
onClusteringBegin={_.noop}
onMouseOut={_.noop}
/>
Before:
<Circle
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<Circle
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
Before:
<Polygon
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<Polygon
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
Before:
<Polyline
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<Polyline
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
Before:
<Rectangle
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<Rectangle
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
Before:
<Marker
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<Marker
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
Before:
<GoogleMap
onClick={_.noop}
onRightclick={_.noop}
onDragstart={_.noop}
/>
After:
<GoogleMap
onClick={_.noop}
onRightClick={_.noop}
onDragStart={_.noop}
/>
withScriptjs
HOC before withGoogleMaps
HOC.Before:
<ScriptjsLoader
hostname={"maps.googleapis.com"}
pathname={"/maps/api/js"}
query={{v: `3.${ AsyncGettingStarted.version }`, libraries: "geometry,drawing,places"}}
loadingElement={
<div {...this.props} style={{ height: "100%" }}>
<FaSpinner />
</div>
}
containerElement={
<div {...this.props} style={{ height: "100%" }} />
}
googleMapElement={
<GoogleMap
ref={googleMap => {
googleMap && console.log(`Zoom: ${ googleMap.getZoom() }`);
}}
defaultZoom={3}
defaultCenter={{lat: -25.363882, lng: 131.044922}}
onClick={::this.handleMapClick}
>
<Marker
{...this.state.marker}
onRightclick={this.handleMarkerRightclick}
/>
</GoogleMap>
}
/>
After:
// Wrap all `react-google-maps` components with `withGoogleMap` HOC
// then wraps it into `withScriptjs` HOC
// It loads Google Maps JavaScript API v3 for you asynchronously.
// Name the component AsyncGettingStartedExampleGoogleMap
const AsyncGettingStartedExampleGoogleMap = withScriptjs(
withGoogleMap(
props => (
<GoogleMap
ref={props.onMapLoad}
defaultZoom={3}
defaultCenter={{ lat: -25.363882, lng: 131.044922 }}
onClick={props.onMapClick}
>
{props.markers.map(marker => (
<Marker
{...marker}
onRightClick={() => props.onMarkerRightClick(marker)}
/>
))}
</GoogleMap>
)
);
// Then, render it:
render(
<GettingStartedGoogleMap
googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp"
loadingElement={
<div style={{ height: `100%` }}>
<FaSpinner
style={{
display: `block`,
width: `80px`,
height: `80px`,
margin: `150px auto`,
animation: `fa-spin 2s infinite linear`,
}}
/>
</div>
}
containerElement={
<div style={{ height: `100%` }} />
}
mapElement={
<div style={{ height: `100%` }} />
}
onMapLoad={_.noop}
onMapClick={_.noop}
markers={markers}
onMarkerRightClick={_.noop}
/>,
document.getElementById('root')
);
Before:
<KmlLayer
onClick={_.noop}
onDefaultviewportChanged={_.noop}
onStatusChanged={_.noop}
/>
After:
<KmlLayer
onClick={_.noop}
onDefaultViewportChanged={_.noop}
onStatusChanged={_.noop}
/>
<a name="5.1.1"></a>