Rename _ol_source_Cluster_ to Cluster
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ import View from '../src/ol/View.js';
|
|||||||
import Point from '../src/ol/geom/Point.js';
|
import Point from '../src/ol/geom/Point.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||||
import _ol_source_Cluster_ from '../src/ol/source/Cluster.js';
|
import Cluster from '../src/ol/source/Cluster.js';
|
||||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
import VectorSource from '../src/ol/source/Vector.js';
|
||||||
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
||||||
@@ -28,7 +28,7 @@ var source = new VectorSource({
|
|||||||
features: features
|
features: features
|
||||||
});
|
});
|
||||||
|
|
||||||
var clusterSource = new _ol_source_Cluster_({
|
var clusterSource = new Cluster({
|
||||||
distance: parseInt(distance.value, 10),
|
distance: parseInt(distance.value, 10),
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
|||||||
import _ol_interaction_Select_ from '../src/ol/interaction/Select.js';
|
import _ol_interaction_Select_ from '../src/ol/interaction/Select.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||||
import _ol_source_Cluster_ from '../src/ol/source/Cluster.js';
|
import Cluster from '../src/ol/source/Cluster.js';
|
||||||
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
|
import _ol_source_Stamen_ from '../src/ol/source/Stamen.js';
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
import VectorSource from '../src/ol/source/Vector.js';
|
||||||
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
||||||
@@ -122,7 +122,7 @@ function selectStyleFunction(feature) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vector = new VectorLayer({
|
vector = new VectorLayer({
|
||||||
source: new _ol_source_Cluster_({
|
source: new Cluster({
|
||||||
distance: 40,
|
distance: 40,
|
||||||
source: new VectorSource({
|
source: new VectorSource({
|
||||||
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
url: 'data/kml/2012_Earthquakes_Mag5.kml',
|
||||||
|
|||||||
+11
-11
@@ -22,7 +22,7 @@ import VectorSource from '../source/Vector.js';
|
|||||||
* @extends {ol.source.Vector}
|
* @extends {ol.source.Vector}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_source_Cluster_ = function(options) {
|
var Cluster = function(options) {
|
||||||
VectorSource.call(this, {
|
VectorSource.call(this, {
|
||||||
attributions: options.attributions,
|
attributions: options.attributions,
|
||||||
extent: options.extent,
|
extent: options.extent,
|
||||||
@@ -67,10 +67,10 @@ var _ol_source_Cluster_ = function(options) {
|
|||||||
this.source = options.source;
|
this.source = options.source;
|
||||||
|
|
||||||
this.source.on(EventType.CHANGE,
|
this.source.on(EventType.CHANGE,
|
||||||
_ol_source_Cluster_.prototype.refresh, this);
|
Cluster.prototype.refresh, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_source_Cluster_, VectorSource);
|
inherits(Cluster, VectorSource);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +78,7 @@ inherits(_ol_source_Cluster_, VectorSource);
|
|||||||
* @return {number} Distance.
|
* @return {number} Distance.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.getDistance = function() {
|
Cluster.prototype.getDistance = function() {
|
||||||
return this.distance;
|
return this.distance;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ _ol_source_Cluster_.prototype.getDistance = function() {
|
|||||||
* @return {ol.source.Vector} Source.
|
* @return {ol.source.Vector} Source.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.getSource = function() {
|
Cluster.prototype.getSource = function() {
|
||||||
return this.source;
|
return this.source;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ _ol_source_Cluster_.prototype.getSource = function() {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.loadFeatures = function(extent, resolution,
|
Cluster.prototype.loadFeatures = function(extent, resolution,
|
||||||
projection) {
|
projection) {
|
||||||
this.source.loadFeatures(extent, resolution, projection);
|
this.source.loadFeatures(extent, resolution, projection);
|
||||||
if (resolution !== this.resolution) {
|
if (resolution !== this.resolution) {
|
||||||
@@ -113,7 +113,7 @@ _ol_source_Cluster_.prototype.loadFeatures = function(extent, resolution,
|
|||||||
* @param {number} distance The distance in pixels.
|
* @param {number} distance The distance in pixels.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.setDistance = function(distance) {
|
Cluster.prototype.setDistance = function(distance) {
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.refresh();
|
this.refresh();
|
||||||
};
|
};
|
||||||
@@ -123,7 +123,7 @@ _ol_source_Cluster_.prototype.setDistance = function(distance) {
|
|||||||
* handle the source changing
|
* handle the source changing
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.refresh = function() {
|
Cluster.prototype.refresh = function() {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.cluster();
|
this.cluster();
|
||||||
this.addFeatures(this.features);
|
this.addFeatures(this.features);
|
||||||
@@ -134,7 +134,7 @@ _ol_source_Cluster_.prototype.refresh = function() {
|
|||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.cluster = function() {
|
Cluster.prototype.cluster = function() {
|
||||||
if (this.resolution === undefined) {
|
if (this.resolution === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ _ol_source_Cluster_.prototype.cluster = function() {
|
|||||||
* @return {ol.Feature} The cluster feature.
|
* @return {ol.Feature} The cluster feature.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
_ol_source_Cluster_.prototype.createCluster = function(features) {
|
Cluster.prototype.createCluster = function(features) {
|
||||||
var centroid = [0, 0];
|
var centroid = [0, 0];
|
||||||
for (var i = features.length - 1; i >= 0; --i) {
|
for (var i = features.length - 1; i >= 0; --i) {
|
||||||
var geometry = this.geometryFunction(features[i]);
|
var geometry = this.geometryFunction(features[i]);
|
||||||
@@ -195,4 +195,4 @@ _ol_source_Cluster_.prototype.createCluster = function(features) {
|
|||||||
cluster.set('features', features);
|
cluster.set('features', features);
|
||||||
return cluster;
|
return cluster;
|
||||||
};
|
};
|
||||||
export default _ol_source_Cluster_;
|
export default Cluster;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import LineString from '../../../../src/ol/geom/LineString.js';
|
|||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||||
import {get as getProjection} from '../../../../src/ol/proj.js';
|
import {get as getProjection} from '../../../../src/ol/proj.js';
|
||||||
import _ol_source_Cluster_ from '../../../../src/ol/source/Cluster.js';
|
import Cluster from '../../../../src/ol/source/Cluster.js';
|
||||||
import Source from '../../../../src/ol/source/Source.js';
|
import Source from '../../../../src/ol/source/Source.js';
|
||||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
|
|
||||||
@@ -11,12 +11,12 @@ describe('ol.source.Cluster', function() {
|
|||||||
|
|
||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('returns a cluster source', function() {
|
it('returns a cluster source', function() {
|
||||||
var source = new _ol_source_Cluster_({
|
var source = new Cluster({
|
||||||
projection: getProjection('EPSG:4326'),
|
projection: getProjection('EPSG:4326'),
|
||||||
source: new VectorSource()
|
source: new VectorSource()
|
||||||
});
|
});
|
||||||
expect(source).to.be.a(Source);
|
expect(source).to.be.a(Source);
|
||||||
expect(source).to.be.a(_ol_source_Cluster_);
|
expect(source).to.be.a(Cluster);
|
||||||
expect(source.getDistance()).to.be(20);
|
expect(source.getDistance()).to.be(20);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -25,7 +25,7 @@ describe('ol.source.Cluster', function() {
|
|||||||
var extent = [-1, -1, 1, 1];
|
var extent = [-1, -1, 1, 1];
|
||||||
var projection = getProjection('EPSG:3857');
|
var projection = getProjection('EPSG:3857');
|
||||||
it('clusters a source with point features', function() {
|
it('clusters a source with point features', function() {
|
||||||
var source = new _ol_source_Cluster_({
|
var source = new Cluster({
|
||||||
source: new VectorSource({
|
source: new VectorSource({
|
||||||
features: [
|
features: [
|
||||||
new Feature(new Point([0, 0])),
|
new Feature(new Point([0, 0])),
|
||||||
@@ -38,7 +38,7 @@ describe('ol.source.Cluster', function() {
|
|||||||
expect(source.getFeatures()[0].get('features').length).to.be(2);
|
expect(source.getFeatures()[0].get('features').length).to.be(2);
|
||||||
});
|
});
|
||||||
it('clusters with a custom geometryFunction', function() {
|
it('clusters with a custom geometryFunction', function() {
|
||||||
var source = new _ol_source_Cluster_({
|
var source = new Cluster({
|
||||||
geometryFunction: function(feature) {
|
geometryFunction: function(feature) {
|
||||||
var geom = feature.getGeometry();
|
var geom = feature.getGeometry();
|
||||||
if (geom.getType() == 'Point') {
|
if (geom.getType() == 'Point') {
|
||||||
@@ -65,7 +65,7 @@ describe('ol.source.Cluster', function() {
|
|||||||
|
|
||||||
describe('#setDistance', function() {
|
describe('#setDistance', function() {
|
||||||
it('changes the distance value', function() {
|
it('changes the distance value', function() {
|
||||||
var source = new _ol_source_Cluster_({
|
var source = new Cluster({
|
||||||
distance: 100,
|
distance: 100,
|
||||||
source: new VectorSource()
|
source: new VectorSource()
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user