-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
192 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Ember from 'ember'; | ||
import GMapClusterer from './g-map-clusterer'; | ||
import GMapMarkerComponent from './g-map-marker'; | ||
|
||
const { isPresent, computed, assert } = Ember; | ||
|
||
const GMapClusterMarkerComponent = GMapMarkerComponent.extend({ | ||
mapContext: computed.alias('clustererContext.mapContext'), | ||
clusterer: computed.alias('clustererContext.clusterer'), | ||
|
||
init() { | ||
this._super(arguments); | ||
|
||
const clustererContext = this.get('clustererContext'); | ||
assert('Must be inside {{#g-map-clusterer}} component with context set', | ||
clustererContext instanceof GMapClusterer); | ||
}, | ||
|
||
unsetMarkerFromMap() { | ||
const marker = this.get('marker'); | ||
const clusterer = this.get('clusterer'); | ||
|
||
if (isPresent(marker) && isPresent(clusterer)) { | ||
clusterer.removeMarker(marker); | ||
} | ||
}, | ||
|
||
setMap() { | ||
const clusterer = this.get('clusterer'); | ||
const marker = this.get('marker'); | ||
|
||
if (isPresent(marker) && isPresent(clusterer)) { | ||
clusterer.addMarker(marker); | ||
} | ||
} | ||
}); | ||
|
||
GMapClusterMarkerComponent.reopenClass({ | ||
positionalParams: ['clustererContext'] | ||
}); | ||
|
||
export default GMapClusterMarkerComponent; |
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,60 @@ | ||
import Ember from 'ember'; | ||
import layout from '../templates/components/g-map-clusterer'; | ||
import GMapComponent from './g-map'; | ||
|
||
const { isEmpty, isPresent, computed, observer, run, assert } = Ember; | ||
|
||
const GMapClustererComponent = Ember.Component.extend({ | ||
layout: layout, | ||
classNames: ['g-map-clusterer'], | ||
|
||
map: computed.oneWay('mapContext.map'), | ||
markers: computed.oneWay('mapContext.markers'), | ||
|
||
init() { | ||
this._super(arguments); | ||
|
||
const mapContext = this.get('mapContext'); | ||
assert('Must be inside {{#g-map}} component with context set', mapContext instanceof GMapComponent); | ||
|
||
if (isEmpty(this.get('options'))) { | ||
this.set('options', {}); | ||
} | ||
}, | ||
|
||
mapWasSet: observer('map', function() { | ||
const map = this.get('map'); | ||
const clusterer = this.get('clusterer'); | ||
|
||
if (isPresent(map) && isEmpty(clusterer)) { | ||
const options = this.get('options'); | ||
this.set('clusterer', new MarkerClusterer(map, [], options)); | ||
} | ||
}), | ||
|
||
willDestroyElement() { | ||
const clusterer = this.get('clusterer'); | ||
|
||
if (isPresent(clusterer)) { | ||
clusterer.clearMarkers(); | ||
} | ||
}, | ||
|
||
markersChanged: observer('markers.@each.lat', 'markers.@each.lng', function() { | ||
run.once(this, 'repaintClusterer'); | ||
}), | ||
|
||
repaintClusterer() { | ||
const clusterer = this.get('clusterer'); | ||
|
||
if (isPresent(clusterer)) { | ||
clusterer.repaint(); | ||
} | ||
} | ||
}); | ||
|
||
GMapClustererComponent.reopenClass({ | ||
positionalParams: ['mapContext'] | ||
}); | ||
|
||
export default GMapClustererComponent; |
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 @@ | ||
{{yield this}} |
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 @@ | ||
export { default } from 'ember-g-map/components/g-map-cluster-marker'; |
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 @@ | ||
export { default } from 'ember-g-map/components/g-map-clusterer'; |
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,6 @@ | ||
{ | ||
"predef": [ | ||
"console" | ||
], | ||
"strict": false | ||
} |
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,7 @@ | ||
module.exports = { | ||
normalizeEntityName: function() {}, | ||
|
||
afterInstall: function() { | ||
return this.addBowerPackageToProject('markerclustererplus', '~2.1.4'); | ||
} | ||
}; |
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,36 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('g-map-cluster-marker', 'Integration | Component | g map cluster marker', { | ||
integration: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
assert.expect(2); | ||
|
||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs` | ||
{{#g-map as |context|}} | ||
{{#g-map-clusterer context as |clustererContext|}} | ||
{{g-map-cluster-marker clustererContext}} | ||
{{/g-map-clusterer}} | ||
{{/g-map}} | ||
`); | ||
|
||
assert.equal(this.$().text().trim(), ''); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
{{#g-map as |context|}} | ||
{{#g-map-clusterer context as |clustererContext|}} | ||
{{#g-map-cluster-marker clustererContext}} | ||
template block text | ||
{{/g-map-cluster-marker}} | ||
{{/g-map-clusterer}} | ||
{{/g-map}} | ||
`); | ||
|
||
assert.equal(this.$().text().trim(), 'template block text'); | ||
}); |
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,32 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('g-map-clusterer', 'Integration | Component | g map clusterer', { | ||
integration: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
assert.expect(2); | ||
|
||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs` | ||
{{#g-map as |context|}} | ||
{{g-map-clusterer context}} | ||
{{/g-map}} | ||
`); | ||
|
||
assert.equal(this.$().text().trim(), ''); | ||
|
||
// Template block usage: | ||
this.render(hbs` | ||
{{#g-map as |context|}} | ||
{{#g-map-clusterer context}} | ||
template block text | ||
{{/g-map-clusterer}} | ||
{{/g-map}} | ||
`); | ||
|
||
assert.equal(this.$().text().trim(), 'template block text'); | ||
}); |