Skip to content

Commit 94d9b44

Browse files
committed
added dist/ directory and updated marked
1 parent 08ed2f2 commit 94d9b44

13 files changed

+1719
-5
lines changed

dist/GoogleApiComponent.js

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define(['exports', 'react', 'react-dom', './lib/ScriptCache', './lib/GoogleApi'], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory(exports, require('react'), require('react-dom'), require('./lib/ScriptCache'), require('./lib/GoogleApi'));
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory(mod.exports, global.react, global.reactDom, global.ScriptCache, global.GoogleApi);
11+
global.GoogleApiComponent = mod.exports;
12+
}
13+
})(this, function (exports, _react, _reactDom, _ScriptCache, _GoogleApi) {
14+
'use strict';
15+
16+
Object.defineProperty(exports, "__esModule", {
17+
value: true
18+
});
19+
exports.wrapper = undefined;
20+
21+
var _react2 = _interopRequireDefault(_react);
22+
23+
var _reactDom2 = _interopRequireDefault(_reactDom);
24+
25+
var _GoogleApi2 = _interopRequireDefault(_GoogleApi);
26+
27+
function _interopRequireDefault(obj) {
28+
return obj && obj.__esModule ? obj : {
29+
default: obj
30+
};
31+
}
32+
33+
function _classCallCheck(instance, Constructor) {
34+
if (!(instance instanceof Constructor)) {
35+
throw new TypeError("Cannot call a class as a function");
36+
}
37+
}
38+
39+
var _createClass = function () {
40+
function defineProperties(target, props) {
41+
for (var i = 0; i < props.length; i++) {
42+
var descriptor = props[i];
43+
descriptor.enumerable = descriptor.enumerable || false;
44+
descriptor.configurable = true;
45+
if ("value" in descriptor) descriptor.writable = true;
46+
Object.defineProperty(target, descriptor.key, descriptor);
47+
}
48+
}
49+
50+
return function (Constructor, protoProps, staticProps) {
51+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
52+
if (staticProps) defineProperties(Constructor, staticProps);
53+
return Constructor;
54+
};
55+
}();
56+
57+
function _possibleConstructorReturn(self, call) {
58+
if (!self) {
59+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
60+
}
61+
62+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
63+
}
64+
65+
function _inherits(subClass, superClass) {
66+
if (typeof superClass !== "function" && superClass !== null) {
67+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
68+
}
69+
70+
subClass.prototype = Object.create(superClass && superClass.prototype, {
71+
constructor: {
72+
value: subClass,
73+
enumerable: false,
74+
writable: true,
75+
configurable: true
76+
}
77+
});
78+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
79+
}
80+
81+
var defaultMapConfig = {};
82+
var defaultCreateCache = function defaultCreateCache(options) {
83+
options = options || {};
84+
var apiKey = options.apiKey;
85+
var libraries = options.libraries || ['places'];
86+
var version = options.version || '3.29';
87+
var language = options.language || 'en';
88+
89+
return (0, _ScriptCache.ScriptCache)({
90+
google: (0, _GoogleApi2.default)({
91+
apiKey: apiKey,
92+
language: language,
93+
libraries: libraries,
94+
version: version
95+
})
96+
});
97+
};
98+
99+
var wrapper = exports.wrapper = function wrapper(options) {
100+
return function (WrappedComponent) {
101+
var createCache = options.createCache || defaultCreateCache;
102+
103+
var Wrapper = function (_React$Component) {
104+
_inherits(Wrapper, _React$Component);
105+
106+
function Wrapper(props, context) {
107+
_classCallCheck(this, Wrapper);
108+
109+
var _this = _possibleConstructorReturn(this, (Wrapper.__proto__ || Object.getPrototypeOf(Wrapper)).call(this, props, context));
110+
111+
_this.scriptCache = createCache(options);
112+
_this.scriptCache.google.onLoad(_this.onLoad.bind(_this));
113+
114+
_this.state = {
115+
loaded: false,
116+
map: null,
117+
google: null
118+
};
119+
return _this;
120+
}
121+
122+
_createClass(Wrapper, [{
123+
key: 'onLoad',
124+
value: function onLoad(err, tag) {
125+
this._gapi = window.google;
126+
127+
this.setState({ loaded: true, google: this._gapi });
128+
}
129+
}, {
130+
key: 'render',
131+
value: function render() {
132+
var props = Object.assign({}, this.props, {
133+
loaded: this.state.loaded,
134+
google: window.google
135+
});
136+
137+
return _react2.default.createElement(
138+
'div',
139+
null,
140+
_react2.default.createElement(WrappedComponent, props),
141+
_react2.default.createElement('div', { ref: 'map' })
142+
);
143+
}
144+
}]);
145+
146+
return Wrapper;
147+
}(_react2.default.Component);
148+
149+
return Wrapper;
150+
};
151+
};
152+
153+
exports.default = wrapper;
154+
});

dist/components/HeatMap.js

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define(['exports', 'react', 'prop-types', '../lib/String'], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory(exports, require('react'), require('prop-types'), require('../lib/String'));
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory(mod.exports, global.react, global.propTypes, global.String);
11+
global.HeatMap = mod.exports;
12+
}
13+
})(this, function (exports, _react, _propTypes, _String) {
14+
'use strict';
15+
16+
Object.defineProperty(exports, "__esModule", {
17+
value: true
18+
});
19+
exports.HeatMap = undefined;
20+
21+
var _react2 = _interopRequireDefault(_react);
22+
23+
var _propTypes2 = _interopRequireDefault(_propTypes);
24+
25+
function _interopRequireDefault(obj) {
26+
return obj && obj.__esModule ? obj : {
27+
default: obj
28+
};
29+
}
30+
31+
function _classCallCheck(instance, Constructor) {
32+
if (!(instance instanceof Constructor)) {
33+
throw new TypeError("Cannot call a class as a function");
34+
}
35+
}
36+
37+
var _createClass = function () {
38+
function defineProperties(target, props) {
39+
for (var i = 0; i < props.length; i++) {
40+
var descriptor = props[i];
41+
descriptor.enumerable = descriptor.enumerable || false;
42+
descriptor.configurable = true;
43+
if ("value" in descriptor) descriptor.writable = true;
44+
Object.defineProperty(target, descriptor.key, descriptor);
45+
}
46+
}
47+
48+
return function (Constructor, protoProps, staticProps) {
49+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
50+
if (staticProps) defineProperties(Constructor, staticProps);
51+
return Constructor;
52+
};
53+
}();
54+
55+
function _possibleConstructorReturn(self, call) {
56+
if (!self) {
57+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
58+
}
59+
60+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
61+
}
62+
63+
function _inherits(subClass, superClass) {
64+
if (typeof superClass !== "function" && superClass !== null) {
65+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
66+
}
67+
68+
subClass.prototype = Object.create(superClass && superClass.prototype, {
69+
constructor: {
70+
value: subClass,
71+
enumerable: false,
72+
writable: true,
73+
configurable: true
74+
}
75+
});
76+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
77+
}
78+
79+
var evtNames = ['click', 'mouseover', 'recenter'];
80+
81+
var wrappedPromise = function wrappedPromise() {
82+
var wrappedPromise = {},
83+
promise = new Promise(function (resolve, reject) {
84+
wrappedPromise.resolve = resolve;
85+
wrappedPromise.reject = reject;
86+
});
87+
wrappedPromise.then = promise.then.bind(promise);
88+
wrappedPromise.catch = promise.catch.bind(promise);
89+
wrappedPromise.promise = promise;
90+
91+
return wrappedPromise;
92+
};
93+
94+
var HeatMap = exports.HeatMap = function (_React$Component) {
95+
_inherits(HeatMap, _React$Component);
96+
97+
function HeatMap() {
98+
_classCallCheck(this, HeatMap);
99+
100+
return _possibleConstructorReturn(this, (HeatMap.__proto__ || Object.getPrototypeOf(HeatMap)).apply(this, arguments));
101+
}
102+
103+
_createClass(HeatMap, [{
104+
key: 'componentDidMount',
105+
value: function componentDidMount() {
106+
this.heatMapPromise = wrappedPromise();
107+
this.renderHeatMap();
108+
}
109+
}, {
110+
key: 'componentDidUpdate',
111+
value: function componentDidUpdate(prevProps) {
112+
if (this.props.map !== prevProps.map || this.props.position !== prevProps.position) {
113+
if (this.heatMap) {
114+
this.heatMap.setMap(null);
115+
this.renderHeatMap();
116+
}
117+
}
118+
}
119+
}, {
120+
key: 'componentWillUnmount',
121+
value: function componentWillUnmount() {
122+
if (this.heatMap) {
123+
this.heatMap.setMap(null);
124+
}
125+
}
126+
}, {
127+
key: 'renderHeatMap',
128+
value: function renderHeatMap() {
129+
var _this2 = this;
130+
131+
var _props = this.props,
132+
map = _props.map,
133+
google = _props.google,
134+
positions = _props.positions,
135+
mapCenter = _props.mapCenter,
136+
icon = _props.icon,
137+
gradient = _props.gradient,
138+
radius = _props.radius,
139+
opacity = _props.opacity;
140+
141+
142+
if (!google) {
143+
return null;
144+
}
145+
146+
positions = positions.map(function (pos) {
147+
return new google.maps.LatLng(pos.lat, pos.lng);
148+
});
149+
150+
var pref = {
151+
map: map,
152+
data: positions
153+
};
154+
155+
this.heatMap = new google.maps.visualization.HeatmapLayer(pref);
156+
157+
this.heatMap.set('gradient', gradient);
158+
159+
this.heatMap.set('radius', radius === undefined ? 20 : radius);
160+
161+
this.heatMap.set('opacity', opacity === undefined ? 0.2 : opacity);
162+
163+
evtNames.forEach(function (e) {
164+
_this2.heatMap.addListener(e, _this2.handleEvent(e));
165+
});
166+
167+
this.heatMapPromise.resolve(this.heatMap);
168+
}
169+
}, {
170+
key: 'getHeatMap',
171+
value: function getHeatMap() {
172+
return this.heatMapPromise;
173+
}
174+
}, {
175+
key: 'handleEvent',
176+
value: function handleEvent(evt) {
177+
var _this3 = this;
178+
179+
return function (e) {
180+
var evtName = 'on' + (0, _String.camelize)(evt);
181+
if (_this3.props[evtName]) {
182+
_this3.props[evtName](_this3.props, _this3.heatMap, e);
183+
}
184+
};
185+
}
186+
}, {
187+
key: 'render',
188+
value: function render() {
189+
return null;
190+
}
191+
}]);
192+
193+
return HeatMap;
194+
}(_react2.default.Component);
195+
196+
HeatMap.propTypes = {
197+
position: _propTypes2.default.object,
198+
map: _propTypes2.default.object,
199+
icon: _propTypes2.default.string
200+
};
201+
202+
evtNames.forEach(function (e) {
203+
return HeatMap.propTypes[e] = _propTypes2.default.func;
204+
});
205+
206+
HeatMap.defaultProps = {
207+
name: 'HeatMap'
208+
};
209+
210+
exports.default = HeatMap;
211+
});

0 commit comments

Comments
 (0)