Skip to content

Commit 9ed99e7

Browse files
committed
Reorganize plugins
1 parent e173e89 commit 9ed99e7

File tree

7 files changed

+102
-33
lines changed

7 files changed

+102
-33
lines changed

plugins/gmaps-heatmap/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This is a heatmap.js plugin to visualize data as a heatmap overlay in Google Maps.
2+
3+
4+
Learn more about how to use heatmap.js and this overlay implementation on the [heatmap website](https://www.patrick-wied.at/static/heatmapjs/?utm_source=npm_gmaps&utm_medium=web)
5+
6+
7+
Google Maps is a trademark of Google Inc. The gmaps-heatmap.js overlay implementation is in no way sponsored or affiliated with Google Inc.

plugins/gmaps-heatmap.js renamed to plugins/gmaps-heatmap/gmaps-heatmap.js

+25-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,39 @@
11
/*
2-
* heatmap.js gmaps overlay
2+
* heatmap.js Google Maps Overlay
33
*
4-
* Copyright (c) 2014, Patrick Wied (http://www.patrick-wied.at)
4+
* Copyright (c) 2008-2016, Patrick Wied (https://www.patrick-wied.at)
55
* Dual-licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
66
* and the Beerware (http://en.wikipedia.org/wiki/Beerware) license.
77
*/
8-
9-
(function (name, context, factory) {
10-
8+
;(function (name, context, factory) {
119
// Supports UMD. AMD, CommonJS/Node.js and browser context
1210
if (typeof module !== "undefined" && module.exports) {
13-
module.exports = factory();
11+
module.exports = factory(
12+
require('heatmap.js'),
13+
require('google-maps')
14+
);
1415
} else if (typeof define === "function" && define.amd) {
15-
define(factory);
16+
define(['heatmap.js', 'google-maps'], factory);
1617
} else {
17-
context[name] = factory();
18+
// browser globals
19+
if (typeof window.h337 === 'undefined') {
20+
throw new Error('heatmap.js must be loaded before the gmaps heatmap plugin');
21+
}
22+
if (typeof window.google === 'undefined') {
23+
throw new Error('Google Maps must be loaded before the gmaps heatmap plugin');
24+
}
25+
context[name] = factory(window.h337, window.google.maps);
1826
}
1927

20-
})("HeatmapOverlay", this, function() {
28+
})("HeatmapOverlay", this, function(h337, gmaps) {
29+
'use strict';
2130

2231
var HeatmapOverlay = function(map, cfg){
2332
this.setMap(map);
2433
this.initialize(cfg || {});
2534
};
2635

27-
HeatmapOverlay.prototype = new google.maps.OverlayView();
28-
36+
HeatmapOverlay.prototype = new gmaps.OverlayView();
2937

3038
HeatmapOverlay.CSS_TRANSFORM = (function() {
3139
var div = document.createElement('div');
@@ -66,13 +74,12 @@
6674
};
6775

6876
HeatmapOverlay.prototype.onAdd = function(){
69-
var h337 = typeof require !== 'undefined' ? require('heatmap.js') : window.h337;
7077
var that = this;
7178

7279
this.getPanes().overlayLayer.appendChild(this.container);
7380

7481

75-
this.changeHandler = google.maps.event.addListener(
82+
this.changeHandler = gmaps.event.addListener(
7683
this.map,
7784
'bounds_changed',
7885
function() { return that.draw(); }
@@ -92,7 +99,7 @@
9299
this.container.parentElement.removeChild(this.container);
93100

94101
if (this.changeHandler) {
95-
google.maps.event.removeListener(this.changeHandler);
102+
gmaps.event.removeListener(this.changeHandler);
96103
this.changeHandler = null;
97104
}
98105

@@ -103,7 +110,7 @@
103110

104111
var bounds = this.map.getBounds();
105112

106-
var topLeft = new google.maps.LatLng(
113+
var topLeft = new gmaps.LatLng(
107114
bounds.getNorthEast().lat(),
108115
bounds.getSouthWest().lng()
109116
);
@@ -146,7 +153,7 @@
146153

147154
bounds = this.map.getBounds();
148155

149-
topLeft = new google.maps.LatLng(
156+
topLeft = new gmaps.LatLng(
150157
bounds.getNorthEast().lat(),
151158
bounds.getSouthWest().lng()
152159
);
@@ -229,7 +236,7 @@
229236

230237
while (len--) {
231238
var entry = data[len];
232-
var latlng = new google.maps.LatLng(entry[latField], entry[lngField]);
239+
var latlng = new gmaps.LatLng(entry[latField], entry[lngField]);
233240
var dataObj = { latlng: latlng };
234241
dataObj[valueField] = entry[valueField];
235242
if (entry.radius) {
@@ -252,7 +259,7 @@
252259
var lngField = this.cfg.lngField || 'lng';
253260
var valueField = this.cfg.valueField || 'value';
254261
var entry = pointOrArray;
255-
var latlng = new google.maps.LatLng(entry[latField], entry[lngField]);
262+
var latlng = new gmaps.LatLng(entry[latField], entry[lngField]);
256263
var dataObj = { latlng: latlng };
257264

258265
dataObj[valueField] = entry[valueField];

plugins/gmaps-heatmap/package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "gmaps-heatmap",
3+
"version": "1.0.2",
4+
"description": "heatmap.js Google Maps Overlay",
5+
"homepage": "https://www.patrick-wied.at/static/heatmapjs/",
6+
"main": "gmaps-heatmap.js",
7+
"dependencies": {
8+
"heatmap.js": "*",
9+
"google-maps": "*"
10+
},
11+
"keywords": [
12+
"heatmap",
13+
"google maps",
14+
"googlemaps",
15+
"gmaps",
16+
"heat",
17+
"heat map",
18+
"heatmaps",
19+
"heat maps",
20+
"map",
21+
"maps"
22+
]
23+
}

plugins/leaflet-heatmap/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This is a heatmap.js plugin to visualize data as a **heatmap overlay with Leaflet**.
2+
3+
4+
Learn more about how to use heatmap.js and this overlay implementation on the [heatmap website](https://www.patrick-wied.at/static/heatmapjs/?utm_source=npm_leaflet&utm_medium=web)

plugins/leaflet-heatmap.js renamed to plugins/leaflet-heatmap/leaflet-heatmap.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
/*
22
* Leaflet Heatmap Overlay
33
*
4-
* Copyright (c) 2014, Patrick Wied (http://www.patrick-wied.at)
4+
* Copyright (c) 2008-2016, Patrick Wied (https://www.patrick-wied.at)
55
* Dual-licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
66
* and the Beerware (http://en.wikipedia.org/wiki/Beerware) license.
77
*/
8-
9-
(function (name, context, factory) {
10-
8+
;(function (name, context, factory) {
119
// Supports UMD. AMD, CommonJS/Node.js and browser context
1210
if (typeof module !== "undefined" && module.exports) {
13-
module.exports = factory();
11+
module.exports = factory(
12+
require('heatmap.js'),
13+
require('leaflet')
14+
);
1415
} else if (typeof define === "function" && define.amd) {
15-
define(factory);
16+
define(['heatmap.js', 'leaflet'], factory);
1617
} else {
17-
context[name] = factory();
18+
// browser globals
19+
if (typeof window.h337 === 'undefined') {
20+
throw new Error('heatmap.js must be loaded before the leaflet heatmap plugin');
21+
}
22+
if (typeof window.L === 'undefined') {
23+
throw new Error('Leaflet must be loaded before the leaflet heatmap plugin');
24+
}
25+
context[name] = factory(window.h337, window.L);
1826
}
1927

20-
})("HeatmapOverlay", this, function () {
28+
})("HeatmapOverlay", this, function (h337, L) {
29+
'use strict';
2130

2231
// Leaflet < 0.8 compatibility
2332
if (typeof L.Layer === 'undefined') {
@@ -37,7 +46,6 @@
3746

3847
onAdd: function (map) {
3948
var size = map.getSize();
40-
var h337 = typeof require !== 'undefined' ? require('heatmap.js') : window.h337;
4149

4250
this._map = map;
4351

@@ -218,11 +226,11 @@
218226
HeatmapOverlay.CSS_TRANSFORM = (function() {
219227
var div = document.createElement('div');
220228
var props = [
221-
'transform',
222-
'WebkitTransform',
223-
'MozTransform',
224-
'OTransform',
225-
'msTransform'
229+
'transform',
230+
'WebkitTransform',
231+
'MozTransform',
232+
'OTransform',
233+
'msTransform'
226234
];
227235

228236
for (var i = 0; i < props.length; i++) {
@@ -231,7 +239,6 @@
231239
return prop;
232240
}
233241
}
234-
235242
return props[0];
236243
})();
237244

plugins/leaflet-heatmap/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "leaflet-heatmap",
3+
"version": "1.0.0",
4+
"description": "heatmap.js Leaflet Overlay",
5+
"homepage": "https://www.patrick-wied.at/static/heatmapjs/",
6+
"main": "leaflet-heatmap.js",
7+
"dependencies": {
8+
"heatmap.js": "*",
9+
"leaflet": "*"
10+
},
11+
"keywords": [
12+
"heatmap",
13+
"leaflet",
14+
"heat",
15+
"heat map",
16+
"heatmaps",
17+
"heat maps",
18+
"map",
19+
"maps"
20+
]
21+
}

0 commit comments

Comments
 (0)