Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Polygon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { Component } from "react";
import { Polygon } from "react-google-maps";

class MapViewPolygon extends Component {
render() {
const {
coordinates,
fillColor,
strokeColor,
strokeWidth,
...rest
} = this.props;

return (
<Polygon
path={coordinates.map((x) => ({
lat: x.latitude,
lng: x.longitude,
}))}
options={{
strokeColor: strokeColor,
strokeWeight: strokeWidth,
fillColor: fillColor,
}}
{...rest}
/>
);
}
}

export default MapViewPolygon;
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withGoogleMap, GoogleMap } from 'react-google-maps';
import Marker from './Marker';
import Polyline from './Polyline';
import Callout from './Callout';
import Polygon from './Polygon';

const GoogleMapContainer = withGoogleMap(props => (
<GoogleMap {...props} ref={props.handleMapMounted} />
Expand Down Expand Up @@ -102,6 +103,7 @@ class MapView extends Component {
MapView.Marker = Marker;
MapView.Polyline = Polyline;
MapView.Callout = Callout;
MapView.Polygon = Polygon;

const styles = StyleSheet.create({
container: {
Expand Down