-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent sending empty options and add marker clustering (#86)
* fix(google-maps-api): prevent sending empty options * feat(marker-cluster): add marker clustering * fix(marker-clustering): pass object straight into function
- Loading branch information
1 parent
2dc1c14
commit 216b359
Showing
5 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { inject } from 'aurelia-dependency-injection'; | ||
import { Configure } from './configure'; | ||
|
||
@inject(Configure) | ||
export class MarkerClustering { | ||
private config: Configure; | ||
|
||
constructor(config) { | ||
this.config = config; | ||
} | ||
|
||
isEnabled() { | ||
return this.config.get('markerCluster') && this.config.get('markerCluster').enable; | ||
} | ||
|
||
loadScript() { | ||
if (!this.isEnabled()) { | ||
return; | ||
} | ||
|
||
let script = document.createElement('script'); | ||
|
||
script.type = 'text/javascript'; | ||
script.src = this.config.get('markerCluster').src; | ||
document.body.appendChild(script); | ||
} | ||
|
||
renderClusters(map, markers) { | ||
if (!this.isEnabled()) { | ||
return; | ||
} | ||
|
||
new (<any>window).MarkerClusterer(map, markers, this.config.get('markerCluster')); | ||
} | ||
} |