markerclustererplus-rails 2.0.16.1 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/markerclusterer.js.erb +69 -88
- data/lib/markerclustererplus-rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72e3cfc9cc563595f309c46868249ccd402a4e1f
|
4
|
+
data.tar.gz: 964fc86c9024fca01c07dd30fb53fe073849e6ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67369f0678981ba8931af04ba1f4ccbe6499cc4ea4f78ccbca8315dfa62b3abf81622338b501965a0a7aa79865a118fbf6e0abc4202ab0dbe4232f0b6545795e
|
7
|
+
data.tar.gz: f90f0d75c39904a685725406e757cc9f5097553f4736149d12e1a0067bb8c1147c59904a0d6aef3aede287617e3ca101269f23a5626665af74eae0afbd31e722
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ The files will be added to the asset pipeline and available for you to use.
|
|
5
5
|
|
6
6
|
For info on how to use the library see the original documentation:
|
7
7
|
|
8
|
-
[MarkerClustererPlus for Google Maps V3](http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.
|
8
|
+
[MarkerClustererPlus for Google Maps V3](http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.1/docs/reference.html)
|
9
9
|
|
10
10
|
MarkerClustererPlus is an enhanced Google Maps V3 implementation of the V2 MarkerClusterer.
|
11
11
|
|
@@ -1,9 +1,6 @@
|
|
1
|
-
/*jslint browser: true, confusion: true, sloppy: true, vars: true, nomen: false, plusplus: false, indent: 2 */
|
2
|
-
/*global window,google */
|
3
|
-
|
4
1
|
/**
|
5
2
|
* @name MarkerClustererPlus for Google Maps V3
|
6
|
-
* @version 2.
|
3
|
+
* @version 2.1 [November 3, 2013]
|
7
4
|
* @author Gary Little
|
8
5
|
* @fileoverview
|
9
6
|
* The library creates and manages per-zoom-level clusters for large amounts of markers.
|
@@ -15,21 +12,20 @@
|
|
15
12
|
* >V3 MarkerClusterer</a> port by Luke Mahe. MarkerClustererPlus was created by Gary Little.
|
16
13
|
* <p>
|
17
14
|
* v2.0 release: MarkerClustererPlus v2.0 is backward compatible with MarkerClusterer v1.0. It
|
18
|
-
* adds support for the <code>ignoreHidden</code>, <code>title</code>, <code>
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
* so please change your application code now.
|
15
|
+
* adds support for the <code>ignoreHidden</code>, <code>title</code>, <code>batchSizeIE</code>,
|
16
|
+
* and <code>calculator</code> properties as well as support for four more events. It also allows
|
17
|
+
* greater control over the styling of the text that appears on the cluster marker. The
|
18
|
+
* documentation has been significantly improved and the overall code has been simplified and
|
19
|
+
* polished. Very large numbers of markers can now be managed without causing Javascript timeout
|
20
|
+
* errors on Internet Explorer. Note that the name of the <code>clusterclick</code> event has been
|
21
|
+
* deprecated. The new name is <code>click</code>, so please change your application code now.
|
26
22
|
*/
|
27
23
|
|
28
24
|
/**
|
29
25
|
* This file modified for use with the Rails asset pipeline
|
30
26
|
* https://github.com/RogerE/markerclustererplus-rails
|
31
27
|
* gem markerclustererplus-rails
|
32
|
-
* gem version 2.
|
28
|
+
* gem version 2.1
|
33
29
|
* @author Roger Ertesvag
|
34
30
|
* NOTE: to include the MarkerClustererPlus icons in the asset pipeline the gem overrides
|
35
31
|
* the original configuration for setting the icon properties. This means that changing
|
@@ -60,36 +56,34 @@
|
|
60
56
|
* style the cluster icon is determined by calling the <code>calculator</code> function.
|
61
57
|
*
|
62
58
|
* @property {string} url The URL of the cluster icon image file. Required.
|
63
|
-
* @property {number} height The height (in pixels) of the cluster icon. Required.
|
64
|
-
* @property {number} width The width (in pixels) of the cluster icon. Required.
|
65
|
-
* @property {Array} [
|
66
|
-
* the
|
67
|
-
*
|
68
|
-
*
|
69
|
-
* than <code>width</code>. The default is to anchor the label text so that it is centered
|
70
|
-
* on the icon.
|
59
|
+
* @property {number} height The display height (in pixels) of the cluster icon. Required.
|
60
|
+
* @property {number} width The display width (in pixels) of the cluster icon. Required.
|
61
|
+
* @property {Array} [anchorText] The position (in pixels) from the center of the cluster icon to
|
62
|
+
* where the text label is to be centered and drawn. The format is <code>[yoffset, xoffset]</code>
|
63
|
+
* where <code>yoffset</code> increases as you go down from center and <code>xoffset</code>
|
64
|
+
* increases to the right of center. The default is <code>[0, 0]</code>.
|
71
65
|
* @property {Array} [anchorIcon] The anchor position (in pixels) of the cluster icon. This is the
|
72
66
|
* spot on the cluster icon that is to be aligned with the cluster position. The format is
|
73
67
|
* <code>[yoffset, xoffset]</code> where <code>yoffset</code> increases as you go down and
|
74
|
-
* <code>xoffset</code> increases to the right
|
75
|
-
* cluster icon.
|
68
|
+
* <code>xoffset</code> increases to the right of the top-left corner of the icon. The default
|
69
|
+
* anchor position is the center of the cluster icon.
|
76
70
|
* @property {string} [textColor="black"] The color of the label text shown on the
|
77
71
|
* cluster icon.
|
78
72
|
* @property {number} [textSize=11] The size (in pixels) of the label text shown on the
|
79
73
|
* cluster icon.
|
80
|
-
* @property {
|
74
|
+
* @property {string} [textDecoration="none"] The value of the CSS <code>text-decoration</code>
|
81
75
|
* property for the label text shown on the cluster icon.
|
82
|
-
* @property {
|
76
|
+
* @property {string} [fontWeight="bold"] The value of the CSS <code>font-weight</code>
|
83
77
|
* property for the label text shown on the cluster icon.
|
84
|
-
* @property {
|
78
|
+
* @property {string} [fontStyle="normal"] The value of the CSS <code>font-style</code>
|
85
79
|
* property for the label text shown on the cluster icon.
|
86
|
-
* @property {
|
80
|
+
* @property {string} [fontFamily="Arial,sans-serif"] The value of the CSS <code>font-family</code>
|
87
81
|
* property for the label text shown on the cluster icon.
|
88
82
|
* @property {string} [backgroundPosition="0 0"] The position of the cluster icon image
|
89
83
|
* within the image defined by <code>url</code>. The format is <code>"xpos ypos"</code>
|
90
84
|
* (the same format as for the CSS <code>background-position</code> property). You must set
|
91
85
|
* this property appropriately when the image defined by <code>url</code> represents a sprite
|
92
|
-
* containing multiple images.
|
86
|
+
* containing multiple images. Note that the position <i>must</i> be specified in px units.
|
93
87
|
*/
|
94
88
|
/**
|
95
89
|
* @name ClusterIconInfo
|
@@ -260,14 +254,24 @@ ClusterIcon.prototype.hide = function () {
|
|
260
254
|
*/
|
261
255
|
ClusterIcon.prototype.show = function () {
|
262
256
|
if (this.div_) {
|
257
|
+
var img = "";
|
258
|
+
// NOTE: values must be specified in px units
|
259
|
+
var bp = this.backgroundPosition_.split(" ");
|
260
|
+
var spriteH = parseInt(bp[0].trim(), 10);
|
261
|
+
var spriteV = parseInt(bp[1].trim(), 10);
|
263
262
|
var pos = this.getPosFromLatLng_(this.center_);
|
264
263
|
this.div_.style.cssText = this.createCss(pos);
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
this.div_.innerHTML = this.sums_.text;
|
264
|
+
img = "<img src='" + this.url_ + "' style='position: absolute; top: " + spriteV + "px; left: " + spriteH + "px; ";
|
265
|
+
if (!this.cluster_.getMarkerClusterer().enableRetinaIcons_) {
|
266
|
+
img += "clip: rect(" + (-1 * spriteV) + "px, " + ((-1 * spriteH) + this.width_) + "px, " +
|
267
|
+
((-1 * spriteV) + this.height_) + "px, " + (-1 * spriteH) + "px);";
|
270
268
|
}
|
269
|
+
img += "'>";
|
270
|
+
// (Would like to use "width: inherit;" below, but doesn't work with MSIE)
|
271
|
+
this.div_.innerHTML = img + "<div style='position: absolute; " +
|
272
|
+
"top: " + this.anchorText_[0] + "px; " +
|
273
|
+
"left: " + this.anchorText_[1] + "px; " +
|
274
|
+
"width: " + this.width_ + "px;'>" + this.sums_.text + "</div>";
|
271
275
|
if (typeof this.sums_.title === "undefined" || this.sums_.title === "") {
|
272
276
|
this.div_.title = this.cluster_.getMarkerClusterer().getTitle();
|
273
277
|
} else {
|
@@ -292,7 +296,7 @@ ClusterIcon.prototype.useStyle = function (sums) {
|
|
292
296
|
this.url_ = style.url;
|
293
297
|
this.height_ = style.height;
|
294
298
|
this.width_ = style.width;
|
295
|
-
this.
|
299
|
+
this.anchorText_ = style.anchorText || [0, 0];
|
296
300
|
this.anchorIcon_ = style.anchorIcon || [parseInt(this.height_ / 2, 10), parseInt(this.width_ / 2, 10)];
|
297
301
|
this.textColor_ = style.textColor || "black";
|
298
302
|
this.textSize_ = style.textSize || 11;
|
@@ -322,38 +326,13 @@ ClusterIcon.prototype.setCenter = function (center) {
|
|
322
326
|
*/
|
323
327
|
ClusterIcon.prototype.createCss = function (pos) {
|
324
328
|
var style = [];
|
325
|
-
|
326
|
-
|
327
|
-
style.push('background-position:' + this.backgroundPosition_ + ';');
|
328
|
-
}
|
329
|
-
|
330
|
-
if (typeof this.anchor_ === 'object') {
|
331
|
-
if (typeof this.anchor_[0] === 'number' && this.anchor_[0] > 0 &&
|
332
|
-
this.anchor_[0] < this.height_) {
|
333
|
-
style.push('height:' + (this.height_ - this.anchor_[0]) +
|
334
|
-
'px; padding-top:' + this.anchor_[0] + 'px;');
|
335
|
-
} else {
|
336
|
-
style.push('height:' + this.height_ + 'px; line-height:' + this.height_ +
|
337
|
-
'px;');
|
338
|
-
}
|
339
|
-
if (typeof this.anchor_[1] === 'number' && this.anchor_[1] > 0 &&
|
340
|
-
this.anchor_[1] < this.width_) {
|
341
|
-
style.push('width:' + (this.width_ - this.anchor_[1]) +
|
342
|
-
'px; padding-left:' + this.anchor_[1] + 'px;');
|
343
|
-
} else {
|
344
|
-
style.push('width:' + this.width_ + 'px; text-align:center;');
|
345
|
-
}
|
346
|
-
} else {
|
347
|
-
style.push('height:' + this.height_ + 'px; line-height:' +
|
348
|
-
this.height_ + 'px; width:' + this.width_ + 'px; text-align:center;');
|
349
|
-
}
|
350
|
-
|
329
|
+
style.push('width:' + this.width_ + 'px; height:' + this.height_ + 'px;');
|
330
|
+
style.push('text-align:center; line-height:' + this.height_ + 'px;');
|
351
331
|
style.push('cursor:pointer; top:' + pos.y + 'px; left:' +
|
352
332
|
pos.x + 'px; color:' + this.textColor_ + '; position:absolute; font-size:' +
|
353
333
|
this.textSize_ + 'px; font-family:' + this.fontFamily_ + '; font-weight:' +
|
354
334
|
this.fontWeight_ + '; font-style:' + this.fontStyle_ + '; text-decoration:' +
|
355
335
|
this.textDecoration_ + ';');
|
356
|
-
|
357
336
|
return style.join("");
|
358
337
|
};
|
359
338
|
|
@@ -368,6 +347,8 @@ ClusterIcon.prototype.getPosFromLatLng_ = function (latlng) {
|
|
368
347
|
var pos = this.getProjection().fromLatLngToDivPixel(latlng);
|
369
348
|
pos.x -= this.anchorIcon_[1];
|
370
349
|
pos.y -= this.anchorIcon_[0];
|
350
|
+
pos.x = parseInt(pos.x, 10);
|
351
|
+
pos.y = parseInt(pos.y, 10);
|
371
352
|
return pos;
|
372
353
|
};
|
373
354
|
|
@@ -385,7 +366,6 @@ function Cluster(mc) {
|
|
385
366
|
this.gridSize_ = mc.getGridSize();
|
386
367
|
this.minClusterSize_ = mc.getMinimumClusterSize();
|
387
368
|
this.averageCenter_ = mc.getAverageCenter();
|
388
|
-
this.printable_ = mc.getPrintable();
|
389
369
|
this.markers_ = [];
|
390
370
|
this.center_ = null;
|
391
371
|
this.bounds_ = null;
|
@@ -627,9 +607,6 @@ Cluster.prototype.isMarkerAlreadyAdded_ = function (marker) {
|
|
627
607
|
* <code>text</code> property of the result returned by the default <code>calculator</code>).
|
628
608
|
* If set to <code>true</code> and you change the visibility of a marker being clustered, be
|
629
609
|
* sure to also call <code>MarkerClusterer.repaint()</code>.
|
630
|
-
* @property {boolean} [printable=false] Whether to make the cluster icons printable. Do not
|
631
|
-
* set to <code>true</code> if the <code>url</code> fields in the <code>styles</code> array
|
632
|
-
* refer to image sprite files.
|
633
610
|
* @property {string} [title=""] The tooltip to display when the mouse moves over a cluster
|
634
611
|
* marker. (Alternatively, you can use a custom <code>calculator</code> function to specify a
|
635
612
|
* different tooltip for each cluster marker.)
|
@@ -658,6 +635,10 @@ Cluster.prototype.isMarkerAlreadyAdded_ = function (marker) {
|
|
658
635
|
* The default is an array of {@link ClusterIconStyle} elements whose properties are derived
|
659
636
|
* from the values for <code>imagePath</code>, <code>imageExtension</code>, and
|
660
637
|
* <code>imageSizes</code>.
|
638
|
+
* @property {boolean} [enableRetinaIcons=false] Whether to allow the use of cluster icons that
|
639
|
+
* have sizes that are some multiple (typically double) of their actual display size. Icons such
|
640
|
+
* as these look better when viewed on high-resolution monitors such as Apple's Retina displays.
|
641
|
+
* Note: if this property is <code>true</code>, sprites cannot be used as cluster icons.
|
661
642
|
* @property {number} [batchSize=MarkerClusterer.BATCH_SIZE] Set this property to the
|
662
643
|
* number of markers to be processed in a single batch when using a browser other than
|
663
644
|
* Internet Explorer (for Internet Explorer, use the batchSizeIE property instead).
|
@@ -721,9 +702,9 @@ function MarkerClusterer(map, opt_markers, opt_options) {
|
|
721
702
|
if (opt_options.ignoreHidden !== undefined) {
|
722
703
|
this.ignoreHidden_ = opt_options.ignoreHidden;
|
723
704
|
}
|
724
|
-
this.
|
725
|
-
if (opt_options.
|
726
|
-
this.
|
705
|
+
this.enableRetinaIcons_ = false;
|
706
|
+
if (opt_options.enableRetinaIcons !== undefined) {
|
707
|
+
this.enableRetinaIcons_ = opt_options.enableRetinaIcons;
|
727
708
|
}
|
728
709
|
this.imagePath_ = opt_options.imagePath || MarkerClusterer.IMAGE_PATH;
|
729
710
|
this.imageExtension_ = opt_options.imageExtension || MarkerClusterer.IMAGE_EXTENSION;
|
@@ -1020,6 +1001,26 @@ MarkerClusterer.prototype.setIgnoreHidden = function (ignoreHidden) {
|
|
1020
1001
|
};
|
1021
1002
|
|
1022
1003
|
|
1004
|
+
/**
|
1005
|
+
* Returns the value of the <code>enableRetinaIcons</code> property.
|
1006
|
+
*
|
1007
|
+
* @return {boolean} True if enableRetinaIcons property is set.
|
1008
|
+
*/
|
1009
|
+
MarkerClusterer.prototype.getEnableRetinaIcons = function () {
|
1010
|
+
return this.enableRetinaIcons_;
|
1011
|
+
};
|
1012
|
+
|
1013
|
+
|
1014
|
+
/**
|
1015
|
+
* Sets the value of the <code>enableRetinaIcons</code> property.
|
1016
|
+
*
|
1017
|
+
* @param {boolean} enableRetinaIcons The value of the enableRetinaIcons property.
|
1018
|
+
*/
|
1019
|
+
MarkerClusterer.prototype.setEnableRetinaIcons = function (enableRetinaIcons) {
|
1020
|
+
this.enableRetinaIcons_ = enableRetinaIcons;
|
1021
|
+
};
|
1022
|
+
|
1023
|
+
|
1023
1024
|
/**
|
1024
1025
|
* Returns the value of the <code>imageExtension</code> property.
|
1025
1026
|
*
|
@@ -1101,26 +1102,6 @@ MarkerClusterer.prototype.setCalculator = function (calculator) {
|
|
1101
1102
|
};
|
1102
1103
|
|
1103
1104
|
|
1104
|
-
/**
|
1105
|
-
* Returns the value of the <code>printable</code> property.
|
1106
|
-
*
|
1107
|
-
* @return {boolean} the value of the printable property.
|
1108
|
-
*/
|
1109
|
-
MarkerClusterer.prototype.getPrintable = function () {
|
1110
|
-
return this.printable_;
|
1111
|
-
};
|
1112
|
-
|
1113
|
-
|
1114
|
-
/**
|
1115
|
-
* Sets the value of the <code>printable</code> property.
|
1116
|
-
*
|
1117
|
-
* @param {boolean} printable The value of the printable property.
|
1118
|
-
*/
|
1119
|
-
MarkerClusterer.prototype.setPrintable = function (printable) {
|
1120
|
-
this.printable_ = printable;
|
1121
|
-
};
|
1122
|
-
|
1123
|
-
|
1124
1105
|
/**
|
1125
1106
|
* Returns the value of the <code>batchSizeIE</code> property.
|
1126
1107
|
*
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markerclustererplus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RogerE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides the MarkerClustererPlus assets for your Rails application.
|
14
14
|
email:
|