UNPKG

react-google-maps-jimmy

Version:
581 lines (491 loc) 14.1 kB
"use strict" Object.defineProperty(exports, "__esModule", { value: true, }) exports.GoogleMap = exports.Map = undefined var _defineProperty2 = require("babel-runtime/helpers/defineProperty") var _defineProperty3 = _interopRequireDefault(_defineProperty2) var _toConsumableArray2 = require("babel-runtime/helpers/toConsumableArray") var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2) var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of") var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf) var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck") var _classCallCheck3 = _interopRequireDefault(_classCallCheck2) var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn") var _possibleConstructorReturn3 = _interopRequireDefault( _possibleConstructorReturn2 ) var _createClass2 = require("babel-runtime/helpers/createClass") var _createClass3 = _interopRequireDefault(_createClass2) var _inherits2 = require("babel-runtime/helpers/inherits") var _inherits3 = _interopRequireDefault(_inherits2) var _invariant = require("invariant") var _invariant2 = _interopRequireDefault(_invariant) var _react = require("react") var _react2 = _interopRequireDefault(_react) var _propTypes = require("prop-types") var _propTypes2 = _interopRequireDefault(_propTypes) var _MapChildHelper = require("../utils/MapChildHelper") var _constants = require("../constants") function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj } } /** * A wrapper around `google.maps.Map` * * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map */ var Map = (exports.Map = (function(_React$PureComponent) { ;(0, _inherits3.default)(Map, _React$PureComponent) ;(0, _createClass3.default)(Map, [ { key: "fitBounds", /** * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map * @public */ value: function fitBounds() { var _context$MAP return (_context$MAP = this.context[_constants.MAP]).fitBounds.apply( _context$MAP, arguments ) }, /** * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map * @public */ }, { key: "panBy", value: function panBy() { var _context$MAP2 return (_context$MAP2 = this.context[_constants.MAP]).panBy.apply( _context$MAP2, arguments ) }, /** * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map * @public */ }, { key: "panTo", value: function panTo() { var _context$MAP3 return (_context$MAP3 = this.context[_constants.MAP]).panTo.apply( _context$MAP3, arguments ) }, /** * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map * @public */ }, { key: "panToBounds", value: function panToBounds() { var _context$MAP4 return (_context$MAP4 = this.context[_constants.MAP]).panToBounds.apply( _context$MAP4, arguments ) }, /* * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map */ }, ]) function Map(props, context) { ;(0, _classCallCheck3.default)(this, Map) var _this = (0, _possibleConstructorReturn3.default)( this, (Map.__proto__ || (0, _getPrototypeOf2.default)(Map)).call( this, props, context ) ) ;(0, _invariant2.default)( !!_this.context[_constants.MAP], "Did you wrap <GoogleMap> component with withGoogleMap() HOC?" ) ;(0, _MapChildHelper.construct)( GoogleMap.propTypes, updaterMap, _this.props, _this.context[_constants.MAP] ) return _this } ;(0, _createClass3.default)(Map, [ { key: "componentDidMount", value: function componentDidMount() { ;(0, _MapChildHelper.componentDidMount)( this, this.context[_constants.MAP], eventMap ) }, }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { ;(0, _MapChildHelper.componentDidUpdate)( this, this.context[_constants.MAP], eventMap, updaterMap, prevProps ) }, }, { key: "componentWillUnmount", value: function componentWillUnmount() { ;(0, _MapChildHelper.componentWillUnmount)(this) }, }, { key: "render", value: function render() { var children = this.props.children return _react2.default.createElement("div", null, children) }, /** * Returns the lat/lng bounds of the current viewport. If more than one copy of the world is visible, the bounds range in longitude from -180 to 180 degrees inclusive. If the map is not yet initialized (i.e. the mapType is still null), or center and zoom have not been set then the result is `null` or `undefined`. * @type LatLngBoundsnullundefined * @public */ }, { key: "getBounds", value: function getBounds() { return this.context[_constants.MAP].getBounds() }, /** * Returns the position displayed at the center of the map. Note that this `LatLng` object is _not_ wrapped. See `[LatLng](#LatLng)` for more information. * @type LatLngLatLngLatLng * @public */ }, { key: "getCenter", value: function getCenter() { return this.context[_constants.MAP].getCenter() }, /** * Returns the clickability of the map icons. A map icon represents a point of interest, also known as a POI. If the returned value is true, then the icons are clickable on the map. * @type boolean * @public */ }, { key: "getClickableIcons", value: function getClickableIcons() { return this.context[_constants.MAP].getClickableIcons() }, /** * * @type Element * @public */ }, { key: "getDiv", value: function getDiv() { return this.context[_constants.MAP].getDiv() }, /** * Returns the compass heading of aerial imagery. The heading value is measured in degrees (clockwise) from cardinal direction North. * @type number * @public */ }, { key: "getHeading", value: function getHeading() { return this.context[_constants.MAP].getHeading() }, /** * * @type MapTypeId|string * @public */ }, { key: "getMapTypeId", value: function getMapTypeId() { return this.context[_constants.MAP].getMapTypeId() }, /** * Returns the current `Projection`. If the map is not yet initialized (i.e. the mapType is still null) then the result is null. Listen to `projection_changed` and check its value to ensure it is not null. * @type ProjectionProjectionprojection_changed * @public */ }, { key: "getProjection", value: function getProjection() { return this.context[_constants.MAP].getProjection() }, /** * Returns the default `StreetViewPanorama` bound to the map, which may be a default panorama embedded within the map, or the panorama set using `setStreetView()`. Changes to the map's `streetViewControl` will be reflected in the display of such a bound panorama. * @type StreetViewPanoramaStreetViewPanoramasetStreetView()streetViewControl * @public */ }, { key: "getStreetView", value: function getStreetView() { return this.context[_constants.MAP].getStreetView() }, /** * Returns the current angle of incidence of the map, in degrees from the viewport plane to the map plane. The result will be `0` for imagery taken directly overhead or `45` for 45° imagery. 45° imagery is only available for `satellite` and `hybrid` map types, within some locations, and at some zoom levels. **Note:** This method does not return the value set by `setTilt`. See `setTilt` for details. * @type number045satellitehybridsetTiltsetTilt * @public */ }, { key: "getTilt", value: function getTilt() { return this.context[_constants.MAP].getTilt() }, /** * * @type number * @public */ }, { key: "getZoom", value: function getZoom() { return this.context[_constants.MAP].getZoom() }, }, ]) return Map })( _react2.default.PureComponent )) /* * ----------------------------------------------------------------------------- * This file is auto-generated from the corresponding file at `src/macros/`. * Please **DO NOT** edit this file directly when creating PRs. * ----------------------------------------------------------------------------- */ Map.displayName = "GoogleMap" Map.propTypes = { /** * @see https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapTypeRegistry * @type Array<[id:string, mapType:MapType|*]> */ defaultExtraMapTypes: _propTypes2.default.arrayOf( _propTypes2.default.arrayOf(_propTypes2.default.any) ), /** * @type LatLng|LatLngLiteral */ defaultCenter: _propTypes2.default.any, /** * @type boolean */ defaultClickableIcons: _propTypes2.default.bool, /** * @type number */ defaultHeading: _propTypes2.default.number, /** * @type MapTypeId|string */ defaultMapTypeId: _propTypes2.default.any, /** * @type MapOptions */ defaultOptions: _propTypes2.default.any, /** * @type StreetViewPanorama */ defaultStreetView: _propTypes2.default.any, /** * @type number */ defaultTilt: _propTypes2.default.number, /** * @type number */ defaultZoom: _propTypes2.default.number, /** * @type LatLng|LatLngLiteral */ center: _propTypes2.default.any, /** * @type boolean */ clickableIcons: _propTypes2.default.bool, /** * @type number */ heading: _propTypes2.default.number, /** * @type MapTypeId|string */ mapTypeId: _propTypes2.default.any, /** * @type MapOptions */ options: _propTypes2.default.any, /** * @type StreetViewPanorama */ streetView: _propTypes2.default.any, /** * @type number */ tilt: _propTypes2.default.number, /** * @type number */ zoom: _propTypes2.default.number, /** * function */ onDblClick: _propTypes2.default.func, /** * function */ onDragEnd: _propTypes2.default.func, /** * function */ onDragStart: _propTypes2.default.func, /** * function */ onMapTypeIdChanged: _propTypes2.default.func, /** * function */ onMouseMove: _propTypes2.default.func, /** * function */ onMouseOut: _propTypes2.default.func, /** * function */ onMouseOver: _propTypes2.default.func, /** * function */ onRightClick: _propTypes2.default.func, /** * function */ onTilesLoaded: _propTypes2.default.func, /** * function */ onBoundsChanged: _propTypes2.default.func, /** * function */ onCenterChanged: _propTypes2.default.func, /** * function */ onClick: _propTypes2.default.func, /** * function */ onDrag: _propTypes2.default.func, /** * function */ onHeadingChanged: _propTypes2.default.func, /** * function */ onIdle: _propTypes2.default.func, /** * function */ onProjectionChanged: _propTypes2.default.func, /** * function */ onResize: _propTypes2.default.func, /** * function */ onTiltChanged: _propTypes2.default.func, /** * function */ onZoomChanged: _propTypes2.default.func, } Map.contextTypes = (0, _defineProperty3.default)( {}, _constants.MAP, _propTypes2.default.object ) var GoogleMap = (exports.GoogleMap = Map) exports.default = Map var eventMap = { onDblClick: "dblclick", onDragEnd: "dragend", onDragStart: "dragstart", onMapTypeIdChanged: "maptypeid_changed", onMouseMove: "mousemove", onMouseOut: "mouseout", onMouseOver: "mouseover", onRightClick: "rightclick", onTilesLoaded: "tilesloaded", onBoundsChanged: "bounds_changed", onCenterChanged: "center_changed", onClick: "click", onDrag: "drag", onHeadingChanged: "heading_changed", onIdle: "idle", onProjectionChanged: "projection_changed", onResize: "resize", onTiltChanged: "tilt_changed", onZoomChanged: "zoom_changed", } var updaterMap = { extraMapTypes: function extraMapTypes(instance, extra) { extra.forEach(function(it) { var _instance$mapTypes return (_instance$mapTypes = instance.mapTypes).set.apply( _instance$mapTypes, (0, _toConsumableArray3.default)(it) ) }) }, center: function center(instance, _center) { instance.setCenter(_center) }, clickableIcons: function clickableIcons(instance, _clickableIcons) { instance.setClickableIcons(_clickableIcons) }, heading: function heading(instance, _heading) { instance.setHeading(_heading) }, mapTypeId: function mapTypeId(instance, _mapTypeId) { instance.setMapTypeId(_mapTypeId) }, options: function options(instance, _options) { instance.setOptions(_options) }, streetView: function streetView(instance, _streetView) { instance.setStreetView(_streetView) }, tilt: function tilt(instance, _tilt) { instance.setTilt(_tilt) }, zoom: function zoom(instance, _zoom) { instance.setZoom(_zoom) }, }