@randy.tarampi/jsx
Version:
Some common JSX components for www.randytarampi.ca
55 lines (42 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.instantiateGoogleMap = exports.instantiateGoogleMapCreator = exports.INSTANTIATE_GOOGLE_MAP = void 0;
var _reduxActions = require("redux-actions");
var _selectors = _interopRequireDefault(require("../../../data/selectors"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var INSTANTIATE_GOOGLE_MAP = "INSTANTIATE_GOOGLE_MAP";
exports.INSTANTIATE_GOOGLE_MAP = INSTANTIATE_GOOGLE_MAP;
var instantiateGoogleMapCreator = function instantiateGoogleMapCreator(getGoogleMap, id) {
return function (dispatch, getState) {
var state = getState();
var googleMap = getGoogleMap();
var googleMapState = _selectors["default"].getMap(state, id);
var payload = {
id: id,
vendor: "google"
};
if (googleMapState && googleMapState.size) {
payload = Object.assign(googleMapState.toJS(), payload);
var googleMapStateObject = googleMapState.toJS();
if (googleMap) {
if (googleMapStateObject.center) {
googleMap.panTo(googleMapStateObject.center);
if (googleMapStateObject.zoom) {
googleMap.setZoom(googleMapStateObject.zoom);
}
} else if (googleMapStateObject.bounds) {
googleMap.panToBounds(googleMapStateObject.bounds);
}
}
}
dispatch(instantiateGoogleMap(payload));
return Promise.resolve(payload);
};
};
exports.instantiateGoogleMapCreator = instantiateGoogleMapCreator;
var instantiateGoogleMap = (0, _reduxActions.createAction)(INSTANTIATE_GOOGLE_MAP);
exports.instantiateGoogleMap = instantiateGoogleMap;
var _default = instantiateGoogleMapCreator;
exports["default"] = _default;