MCPcopy Index your code
hub / github.com/google-map-react/google-map-react / componentDidUpdate

Method componentDidUpdate

src/google_map.js:315–434  ·  view source on GitHub ↗
(prevProps)

Source from the content-addressed store, hash-verified

313 }
314
315 componentDidUpdate(prevProps) {
316 if (process.env.NODE_ENV !== 'production') {
317 if (!shallowEqual(prevProps.defaultCenter, this.props.defaultCenter)) {
318 console.warn(
319 "GoogleMap: defaultCenter prop changed. You can't change default props."
320 );
321 }
322
323 if (!shallowEqual(prevProps.defaultZoom, this.props.defaultZoom)) {
324 console.warn(
325 "GoogleMap: defaultZoom prop changed. You can't change default props."
326 );
327 }
328 }
329
330 if (
331 !this._isCenterDefined(prevProps.center) &&
332 this._isCenterDefined(this.props.center)
333 ) {
334 setTimeout(() => this._initMap(), 0);
335 }
336
337 if (this.map_) {
338 const centerLatLng = this.geoService_.getCenter();
339 if (this._isCenterDefined(this.props.center)) {
340 const currentCenter = latLng2Obj(this.props.center);
341 const prevCenter = this._isCenterDefined(prevProps.center)
342 ? latLng2Obj(prevProps.center)
343 : null;
344
345 if (
346 !prevCenter ||
347 Math.abs(currentCenter.lat - prevCenter.lat) +
348 Math.abs(currentCenter.lng - prevCenter.lng) >
349 kEPS
350 ) {
351 if (
352 Math.abs(currentCenter.lat - centerLatLng.lat) +
353 Math.abs(currentCenter.lng - centerLatLng.lng) >
354 kEPS
355 ) {
356 this.map_.panTo({
357 lat: currentCenter.lat,
358 lng: currentCenter.lng,
359 });
360 }
361 }
362 }
363
364 if (!isEmpty(this.props.zoom)) {
365 // if zoom chaged by user
366 if (Math.abs(this.props.zoom - prevProps.zoom) > 0) {
367 this.map_.setZoom(this.props.zoom);
368 }
369 }
370
371 if (!isEmpty(prevProps.draggable) && isEmpty(this.props.draggable)) {
372 // reset to default

Callers

nothing calls this directly

Calls 7

shallowEqualFunction · 0.85
latLng2ObjFunction · 0.85
isEmptyFunction · 0.85
pickFunction · 0.85
omitFunction · 0.85
_checkMinZoomFunction · 0.85
getCenterMethod · 0.80

Tested by

no test coverage detected