import { isEqual } from "lodash" ; import * as ReactDOM from "react-dom" ; import { HEREMapProps } from "../HEREMap" ; import mixin from "../utils/mixin" ; export const HMapMethods = mixin ( { getElement ( ) { return ReactDOM . findDOMNode ( this ) ; } , getMap ( ) { return this . state . map ; } , setCenter ( point ) { const { animateCenter } = this . props ; const { map } = this . state ; map . setCenter ( point , animateCenter === true ) ; } , setZoom ( zoom ) { const { animateZoom } = this . props ; const { map } = this . state ; map . setZoom ( zoom , animateZoom === true ) ; } , componentWillReceiveProps ( nextProps ) { if ( ! isEqual ( nextProps . center , this . props . center ) ) { this . setCenter ( nextProps . center ) ; } if ( nextProps . zoom !== this . props . zoom ) { this . setZoom ( nextProps . zoom ) ; } } , } ) ; export default HMapMethods ;