|
121 | 121 | _inherits(Circle, _React$Component);
|
122 | 122 |
|
123 | 123 | function Circle() {
|
| 124 | + var _ref; |
| 125 | + |
| 126 | + var _temp, _this, _ret; |
| 127 | + |
124 | 128 | _classCallCheck(this, Circle);
|
125 | 129 |
|
126 |
| - return _possibleConstructorReturn(this, (Circle.__proto__ || Object.getPrototypeOf(Circle)).apply(this, arguments)); |
| 130 | + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { |
| 131 | + args[_key] = arguments[_key]; |
| 132 | + } |
| 133 | + |
| 134 | + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Circle.__proto__ || Object.getPrototypeOf(Circle)).call.apply(_ref, [this].concat(args))), _this), _this.centerChanged = function (newCenter) { |
| 135 | + var _this$props$center = _this.props.center, |
| 136 | + lat = _this$props$center.lat, |
| 137 | + lng = _this$props$center.lng; |
| 138 | + |
| 139 | + return lat !== newCenter.lat || lng !== newCenter.lng; |
| 140 | + }, _this.propsChanged = function (newProps) { |
| 141 | + if (_this.centerChanged(newProps.center)) return true; |
| 142 | + |
| 143 | + return Object.keys(Circle.propTypes).some(function (key) { |
| 144 | + return _this.props[key] !== newProps[key]; |
| 145 | + }); |
| 146 | + }, _this.destroyCircle = function () { |
| 147 | + if (_this.circle) { |
| 148 | + _this.circle.setMap(null); |
| 149 | + } |
| 150 | + }, _temp), _possibleConstructorReturn(_this, _ret); |
127 | 151 | }
|
128 | 152 |
|
129 | 153 | _createClass(Circle, [{
|
|
135 | 159 | }, {
|
136 | 160 | key: 'componentDidUpdate',
|
137 | 161 | value: function componentDidUpdate(prevProps) {
|
138 |
| - if (this.props.map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(this.props.path, prevProps.path)) { |
139 |
| - if (this.circle) { |
140 |
| - this.circle.setMap(null); |
141 |
| - } |
| 162 | + var _props = this.props, |
| 163 | + path = _props.path, |
| 164 | + map = _props.map; |
| 165 | + |
| 166 | + |
| 167 | + if (this.propsChanged(prevProps) || map !== prevProps.map || !(0, _arePathsEqual.arePathsEqual)(path, prevProps.path)) { |
| 168 | + this.destroyCircle(); |
142 | 169 | this.renderCircle();
|
143 | 170 | }
|
144 | 171 | }
|
145 | 172 | }, {
|
146 | 173 | key: 'componentWillUnmount',
|
147 | 174 | value: function componentWillUnmount() {
|
148 |
| - if (this.circle) { |
149 |
| - this.circle.setMap(null); |
150 |
| - } |
| 175 | + this.destroyCircle(); |
151 | 176 | }
|
152 | 177 | }, {
|
153 | 178 | key: 'renderCircle',
|
154 | 179 | value: function renderCircle() {
|
155 | 180 | var _this2 = this;
|
156 | 181 |
|
157 |
| - var _props = this.props, |
158 |
| - map = _props.map, |
159 |
| - google = _props.google, |
160 |
| - center = _props.center, |
161 |
| - radius = _props.radius, |
162 |
| - strokeColor = _props.strokeColor, |
163 |
| - strokeOpacity = _props.strokeOpacity, |
164 |
| - strokeWeight = _props.strokeWeight, |
165 |
| - fillColor = _props.fillColor, |
166 |
| - fillOpacity = _props.fillOpacity, |
167 |
| - draggable = _props.draggable, |
168 |
| - visible = _props.visible, |
169 |
| - props = _objectWithoutProperties(_props, ['map', 'google', 'center', 'radius', 'strokeColor', 'strokeOpacity', 'strokeWeight', 'fillColor', 'fillOpacity', 'draggable', 'visible']); |
| 182 | + var _props2 = this.props, |
| 183 | + map = _props2.map, |
| 184 | + google = _props2.google, |
| 185 | + center = _props2.center, |
| 186 | + radius = _props2.radius, |
| 187 | + strokeColor = _props2.strokeColor, |
| 188 | + strokeOpacity = _props2.strokeOpacity, |
| 189 | + strokeWeight = _props2.strokeWeight, |
| 190 | + fillColor = _props2.fillColor, |
| 191 | + fillOpacity = _props2.fillOpacity, |
| 192 | + draggable = _props2.draggable, |
| 193 | + visible = _props2.visible, |
| 194 | + props = _objectWithoutProperties(_props2, ['map', 'google', 'center', 'radius', 'strokeColor', 'strokeOpacity', 'strokeWeight', 'fillColor', 'fillOpacity', 'draggable', 'visible']); |
170 | 195 |
|
171 | 196 | if (!google) {
|
172 | 197 | return null;
|
173 | 198 | }
|
174 | 199 |
|
175 |
| - var params = _extends({ |
| 200 | + var params = _extends({}, props, { |
176 | 201 | map: map,
|
177 | 202 | center: center,
|
178 | 203 | radius: radius,
|
179 |
| - strokeColor: strokeColor, |
180 |
| - strokeOpacity: strokeOpacity, |
181 |
| - strokeWeight: strokeWeight, |
182 |
| - fillColor: fillColor, |
183 |
| - fillOpacity: fillOpacity, |
184 | 204 | draggable: draggable,
|
185 |
| - visible: visible |
186 |
| - }, props); |
| 205 | + visible: visible, |
| 206 | + options: { |
| 207 | + strokeColor: strokeColor, |
| 208 | + strokeOpacity: strokeOpacity, |
| 209 | + strokeWeight: strokeWeight, |
| 210 | + fillColor: fillColor, |
| 211 | + fillOpacity: fillOpacity |
| 212 | + } |
| 213 | + }); |
187 | 214 |
|
188 | 215 | this.circle = new google.maps.Circle(params);
|
189 | 216 |
|
|
227 | 254 | strokeOpacity: _propTypes2.default.number,
|
228 | 255 | strokeWeight: _propTypes2.default.number,
|
229 | 256 | fillColor: _propTypes2.default.string,
|
230 |
| - fillOpacity: _propTypes2.default.number |
| 257 | + fillOpacity: _propTypes2.default.number, |
| 258 | + draggable: _propTypes2.default.bool, |
| 259 | + visible: _propTypes2.default.bool |
231 | 260 | };
|
232 | 261 |
|
233 | 262 | evtNames.forEach(function (e) {
|
|
0 commit comments