Skip to content

new cluster image location (Google switched from googlecode to github) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bf760ee
new cluster image location (Google switched from googlecode to github)
Sep 28, 2016
4118eb5
fix errors being thrown due to the new .extend() notation for the opt…
Sep 28, 2016
f52d049
features of type LineString are now working
Sep 28, 2016
3e0d6f1
Update bower.json
Connum Sep 28, 2016
137363b
added cluster marker images and newly created svg versions
Sep 28, 2016
ba80d93
minified marker svg versions
Sep 28, 2016
6f4b39d
new marker image path using rawgit CDN, uses SVG depending on feature…
Sep 28, 2016
400a073
new marker image path using rawgit CDN, uses SVG depending on feature…
Sep 28, 2016
6fb3272
removed TODO
Sep 28, 2016
3519994
override addListener() inherited by google.maps.OverlayView
Sep 28, 2016
3381c49
style
Sep 29, 2016
5868b96
clustering working for polygons as well
Sep 29, 2016
86fa57b
short writing style (might be a bit more performant than if/else)
Sep 29, 2016
17f2e60
Update README.md
Connum Sep 29, 2016
1713add
Update README.md
Connum Sep 29, 2016
b50b4e2
new option 'setProperty':
Sep 29, 2016
4f70884
Update README.md
Connum Sep 29, 2016
c1737ba
make the property name 'in_cluster' configurable with the constant Da…
Sep 29, 2016
8fe39a5
Update README.md
Connum Sep 29, 2016
4c16f58
fix: it was not possible to set setReady(false)
Sep 30, 2016
1d8591f
performance optimization: redrawing was triggered too often initially
Sep 30, 2016
8aa83bf
fix: if setProperty is true, ignore all markers that are hidden even …
Sep 30, 2016
3b7d604
if the setProperty option is true, trigger a redraw on setStyle()
Sep 30, 2016
6844fe3
updated version to version in the jsdocs section (1.0.0) to make it d…
Sep 30, 2016
1cdb097
new recolorSvg option
Sep 30, 2016
a9af715
fixed handling of recolorSVG option (could only be turned off by an e…
Sep 30, 2016
dd75189
fixed case in recolorSVG option in the jsdocs
Sep 30, 2016
2ef00e0
restructured initialization in order to prevent js erros when recolor…
Sep 30, 2016
b4c31fd
Update README.md
Connum Oct 1, 2016
2590a17
Update README.md
Connum Oct 1, 2016
d826cf9
new option minimumPolySize, updated package.json, increased version n…
Oct 10, 2016
0c6c03a
Update README.md
Connum Oct 10, 2016
b5ef48c
Update README.md
Connum Oct 10, 2016
7da81f6
FeatureCluster.addFeature - Avoid doing twice the work
Dec 27, 2016
10da8be
Remove setStyle within init which did not allow our own setStyle
Dec 27, 2016
de90f4a
Merge pull request #1 from QueenCityCodeFactory/optimize-add-feature
Connum Feb 3, 2017
9d33d3b
Merge pull request #2 from QueenCityCodeFactory/remove-init-style-ove…
Connum Feb 3, 2017
07f331b
coding style
Feb 3, 2017
acda46b
performance optimization: do not recalculate center if _center is alr…
Connum Feb 24, 2017
8884026
performance: removed unnecessary expensive loop over features
Connum Feb 24, 2017
e792ca6
some minor performance improvement (prevents flickering): do not redr…
Connum Feb 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ A Google Maps JavaScript API v3 library to create and manage per-zoom-level clus

Based on [Marker Clusterer – A Google Maps JavaScript API utility library](https://github.com/googlemaps/js-marker-clusterer) by Luke Mehe (Google Inc.).

You can find the minified JS file [in the releases tab](https://github.com/Connum/data-layer-clusterer/releases).

## About this fork

While working with the data layer feature was fun because of the simplicity of adding and getting map content via GeoJSON, I soon encountered the problem of too many markers, lines and polygons being displayed when zooming out of the map. I knew about the marker clusterer for normal layers, but it took me browsing through several StackOverflow posts and pages of search results to stumble upon nantunes' approach to data layers.

Seeing that there hadn't been any work done on the project for almost a year, I tried out jesusr's fork, which included some fixes/optimizations, but out-of-the-box it would just throw JS errors in the console. After forking it and getting it to work, I had to find out that just like the version in the initial repo, there was no support for LineStrings or Polygons, which I needed. Also, the URL to the cluster marker icons was no longer valid, so that had to be fixed as well, and so I did.

My current implementation now includes the following changes:
- Fixed cluster marker image URLs
- Added SVG versions of the marker images which will be used by default if supported by the browser and falls back to the PNG versions
- LineStrings and Polygons are being clustered as well, using the center point of their bounding rectangles
- new option 'setProperty': If set to true, instead of changing the StyleOption attribute 'visible' of the features directly, a boolean property 'in_cluster' (or a configurable property name defined in the constant DataLayerClusterer.CLUSTER_PROPERTY_NAME) is set on the features, which can then be used to toggle visibility (for example in order to take into account other properties for additonal filtering)
- new option 'recolorSvg': (string) only takes action if SVG is supported and being used: a selector string for an SVG element in the set imagePath that can be used for re-coloring the cluster marker image. This saves requests and prevents the different marker images popping up after loading.
- new option: 'minimumPolySize': (number) The minimum width or height of the bounding box of a feature (other than type 'Point') in pixels before it is forced into a cluster, even if the cluster ends up containing only this one feature. 0 or false to disable this functionality. Defaults to 50.

To read more and view a working example, see my blog post at www.constantinmedia.com/2016/09/google-maps-javascript-api-v3-handling-large-amounts-of-features-using-clustering-in-data-layers/

## More to come
- When LineStrings and Polygons are becoming too small according to the minimumPolySize option, display a marker instead for better visibility.

## License

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
7 changes: 4 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "data-layer-clusterer",
"version": "0.7.3",
"homepage": "https://github.com/nantunes/data-layer-clusterer",
"version": "1.0.1",
"homepage": "https://github.com/Connum/data-layer-clusterer",
"authors": [
"Nelson Antunes"
],
"description": "The library creates and manages per-zoom-level clusters large amounts of data layer features. Google API v3.",
"description": "The library creates and manages per-zoom-level clusters for large amounts of data layer features. Google API v3.",
"main": "src/datalayerclusterer.js",
"keywords": [
"google",
"maps",
"data",
"layer",
"features",
"marker",
"cluster",
"clusterer",
Expand Down
Binary file added images/m1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/m1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/m2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/m2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/m3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/m3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/m4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/m4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/m5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/m5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "data-layer-clusterer",
"version": "0.7.3",
"homepage": "https://github.com/nantunes/data-layer-clusterer",
"version": "1.0.1",
"homepage": "https://github.com/Connum/data-layer-clusterer",
"authors": [
"Nelson Antunes"
],
"description": "The library creates and manages per-zoom-level clusters large amounts of data layer features. Google API v3.",
"description": "The library creates and manages per-zoom-level clusters for large amounts of data layer features. Google API v3.",
"main": "src/datalayerclusterer.js",
"keywords": [
"google",
"maps",
"data",
"layer",
"features",
"marker",
"cluster",
"clusterer",
Expand Down
Loading