Skip to content

Commit 03aee4d

Browse files
committed
feat(src): update composeOptions to accept controlledPropTypes for _2
* Ref #130 * Ref #125 * Ref #121 * Ref #112 * Ref #107 * Ref #107
1 parent 777fd83 commit 03aee4d

14 files changed

+84
-95
lines changed

src/addons/addonsCreators/InfoBoxCreator.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import {default as componentLifecycleDecorator} from "../../utils/componentLifec
1414
import {default as GoogleMapHolder} from "../../creators/GoogleMapHolder";
1515

1616
export const infoBoxControlledPropTypes = {
17+
// NOTICE!!!!!!
18+
//
19+
// Only expose those with getters & setters in the table as controlled props.
20+
//
1721
// http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
1822
content: PropTypes.any,
1923
options: PropTypes.object,
@@ -57,13 +61,7 @@ export default class InfoBoxCreator extends Component {
5761
// a isomorphic server.
5862
const GoogleMapsInfobox = require("google-maps-infobox");
5963
// http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
60-
const infoBox = new GoogleMapsInfobox(composeOptions(infoBoxProps, [
61-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference
62-
"content",
63-
"position",
64-
"visible",
65-
"zIndex",
66-
]));
64+
const infoBox = new GoogleMapsInfobox(composeOptions(infoBoxProps, infoBoxControlledPropTypes));
6765

6866
if (infoBoxProps.children) {
6967
setContentForOptionalReactElement(infoBoxProps.children, infoBox);

src/creators/CircleCreator.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1313
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1414

1515
export const circleControlledPropTypes = {
16+
// NOTICE!!!!!!
17+
//
18+
// Only expose those with getters & setters in the table as controlled props.
19+
//
1620
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
21+
//
1722
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Circle
1823
center: PropTypes.any,
1924
draggable: PropTypes.bool,
@@ -53,14 +58,7 @@ export default class CircleCreator extends Component {
5358
static _createCircle (circleProps) {
5459
const {mapHolderRef} = circleProps;
5560
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Circle
56-
const circle = new google.maps.Circle(composeOptions(circleProps, [
57-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#CircleOptions
58-
"center",
59-
"draggable",
60-
"editable",
61-
"radius",
62-
"visible",
63-
]));
61+
const circle = new google.maps.Circle(composeOptions(circleProps, circleControlledPropTypes));
6462

6563
circle.setMap(mapHolderRef.getMap());
6664

src/creators/DirectionsRendererCreator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1414
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1515

1616
export const directionsRendererControlledPropTypes = {
17+
// NOTICE!!!!!!
18+
//
19+
// Only expose those with getters & setters in the table as controlled props.
20+
//
1721
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
22+
//
1823
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsRenderer
1924
directions: PropTypes.any,
2025
options: PropTypes.object,
@@ -50,12 +55,7 @@ export default class DirectionsRendererCreator extends Component {
5055
static _createDirectionsRenderer (directionsRendererProps) {
5156
const {mapHolderRef} = directionsRendererProps;
5257
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsRenderer
53-
const directionsRenderer = new google.maps.DirectionsRenderer(composeOptions(directionsRendererProps, [
54-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DirectionsRendererOptions
55-
"directions",
56-
"panel",
57-
"routeIndex",
58-
]));
58+
const directionsRenderer = new google.maps.DirectionsRenderer(composeOptions(directionsRendererProps, directionsRendererControlledPropTypes));
5959

6060
directionsRenderer.setMap(mapHolderRef.getMap());
6161

src/creators/DrawingManagerCreator.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1313
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1414

1515
export const drawingManagerControlledPropTypes = {
16+
// NOTICE!!!!!!
17+
//
18+
// Only expose those with getters & setters in the table as controlled props.
19+
//
1620
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
21+
//
1722
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DrawingManager
1823
drawingMode: PropTypes.any,
1924
options: PropTypes.object,
@@ -45,10 +50,7 @@ export default class DrawingManagerCreator extends Component {
4550
static _createDrawingManager (drawingManagerProps) {
4651
const {mapHolderRef} = drawingManagerProps;
4752
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DrawingManager
48-
const drawingManager = new google.maps.drawing.DrawingManager(composeOptions(drawingManagerProps, [
49-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#DrawingManagerOptions
50-
"drawingMode",
51-
]));
53+
const drawingManager = new google.maps.drawing.DrawingManager(composeOptions(drawingManagerProps, drawingManagerControlledPropTypes));
5254

5355
drawingManager.setMap(mapHolderRef.getMap());
5456

src/creators/GoogleMapHolder.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import {default as composeOptions} from "../utils/composeOptions";
1212
import {default as componentLifecycleDecorator} from "../utils/componentLifecycleDecorator";
1313

1414
export const mapControlledPropTypes = {
15+
// NOTICE!!!!!!
16+
//
17+
// Only expose those with getters & setters in the table as controlled props.
18+
//
1519
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
20+
//
1621
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
1722
center: PropTypes.object,
1823
heading: PropTypes.number,
@@ -52,15 +57,7 @@ export default class GoogleMapHolder extends Component {
5257

5358
static _createMap (domEl, mapProps) {
5459
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map
55-
return new google.maps.Map(domEl, composeOptions(mapProps, [
56-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapOptions
57-
"center",
58-
"heading",
59-
"mapTypeId",
60-
"streetView",
61-
"tilt",
62-
"zoom",
63-
]));
60+
return new google.maps.Map(domEl, composeOptions(mapProps, mapControlledPropTypes));
6461
}
6562

6663
getMap () {

src/creators/InfoWindowCreator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1414
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1515

1616
export const infoWindowControlledPropTypes = {
17+
// NOTICE!!!!!!
18+
//
19+
// Only expose those with getters & setters in the table as controlled props.
20+
//
1721
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
22+
//
1823
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#InfoWindow
1924
content: PropTypes.any,
2025
options: PropTypes.object,
@@ -52,12 +57,7 @@ export default class InfoWindowCreator extends Component {
5257
static _createInfoWindow (infoWindowProps) {
5358
const {mapHolderRef, anchorHolderRef} = infoWindowProps;
5459
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#InfoWindow
55-
const infoWindow = new google.maps.InfoWindow(composeOptions(infoWindowProps, [
56-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#InfoWindowOptions
57-
"content",
58-
"position",
59-
"zIndex",
60-
]));
60+
const infoWindow = new google.maps.InfoWindow(composeOptions(infoWindowProps, infoWindowControlledPropTypes));
6161

6262
if (infoWindowProps.children) {
6363
setContentForOptionalReactElement(infoWindowProps.children, infoWindow);

src/creators/MarkerCreator.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1414
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1515

1616
export const markerControlledPropTypes = {
17+
// NOTICE!!!!!!
18+
//
19+
// Only expose those with getters & setters in the table as controlled props.
20+
//
1721
// [].map.call($0.querySelectorAll("tr>td>code", function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
22+
//
1823
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Marker
1924
animation: PropTypes.any,
2025
attribution: PropTypes.any,
@@ -72,23 +77,7 @@ export default class MarkerCreator extends Component {
7277
static _createMarker (markerProps) {
7378
const {mapHolderRef} = markerProps;
7479
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Marker
75-
const marker = new google.maps.Marker(composeOptions(markerProps, [
76-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#MarkerOptions
77-
"animation",
78-
"attribution",
79-
"clickable",
80-
"cursor",
81-
"draggable",
82-
"icon",
83-
"label",
84-
"opacity",
85-
"place",
86-
"position",
87-
"shape",
88-
"title",
89-
"visible",
90-
"zIndex",
91-
]));
80+
const marker = new google.maps.Marker(composeOptions(markerProps, markerControlledPropTypes));
9281

9382
marker.setMap(mapHolderRef.getMap());
9483

src/creators/OverlayViewCreator.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ export const overlayViewControlledPropTypes = {
1616
mapPaneName: PropTypes.string,
1717
getPixelPositionOffset: PropTypes.func,
1818
position: PropTypes.object,
19+
children: PropTypes.node,
20+
// NOTICE!!!!!!
21+
//
22+
// Only expose those with getters & setters in the table as controlled props.
23+
//
1924
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
25+
//
2026
// https://developers.google.com/maps/documentation/javascript/3.exp/reference
2127
};
2228

@@ -33,12 +39,7 @@ export default class OverlayViewCreator extends Component {
3339
const {mapHolderRef} = overlayViewProps;
3440
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#OverlayView
3541
const overlayView = new google.maps.OverlayView();
36-
overlayView.setValues(composeOptions(overlayViewProps, [
37-
"mapPaneName",
38-
"getPixelPositionOffset",
39-
"position",
40-
"children",
41-
]));
42+
overlayView.setValues(composeOptions(overlayViewProps, overlayViewControlledPropTypes));
4243

4344
overlayView.onAdd = function () {
4445
this._containerElement = document.createElement("div");

src/creators/PolygonCreator.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1313
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1414

1515
export const polygonControlledPropTypes = {
16+
// NOTICE!!!!!!
17+
//
18+
// Only expose those with getters & setters in the table as controlled props.
19+
//
1620
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
21+
//
1722
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polygon
1823
draggable: PropTypes.bool,
1924
editable: PropTypes.bool,
@@ -53,13 +58,7 @@ export default class PolygonCreator extends Component {
5358
static _createPolygon (polygonProps) {
5459
const {mapHolderRef} = polygonProps;
5560
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polygon
56-
const polygon = new google.maps.Polygon(composeOptions(polygonProps, [
57-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#PolygonOptions
58-
"draggable",
59-
"editable",
60-
"paths",
61-
"visible",
62-
]));
61+
const polygon = new google.maps.Polygon(composeOptions(polygonProps, polygonControlledPropTypes));
6362

6463
polygon.setMap(mapHolderRef.getMap());
6564

src/creators/PolylineCreator.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import {default as componentLifecycleDecorator} from "../utils/componentLifecycl
1313
import {default as GoogleMapHolder} from "./GoogleMapHolder";
1414

1515
export const polylineControlledPropTypes = {
16+
// NOTICE!!!!!!
17+
//
18+
// Only expose those with getters & setters in the table as controlled props.
19+
//
1620
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^set/) && !it.match(/^setMap/); })
21+
//
1722
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline
1823
draggable: PropTypes.bool,
1924
editable: PropTypes.bool,
@@ -51,13 +56,7 @@ export default class PolylineCreator extends Component {
5156
static _createPolyline (polylineProps) {
5257
const {mapHolderRef} = polylineProps;
5358
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#Polyline
54-
const polyline = new google.maps.Polyline(composeOptions(polylineProps, [
55-
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#PolylineOptions
56-
"draggable",
57-
"editable",
58-
"path",
59-
"visible",
60-
]));
59+
const polyline = new google.maps.Polyline(composeOptions(polylineProps, polylineControlledPropTypes));
6160

6261
polyline.setMap(mapHolderRef.getMap());
6362

0 commit comments

Comments
 (0)