Remove goog.isDef from heatmaplayer
This commit is contained in:
@@ -4,6 +4,7 @@ goog.require('goog.asserts');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('goog.object');
|
goog.require('goog.object');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.dom');
|
goog.require('ol.dom');
|
||||||
goog.require('ol.layer.Vector');
|
goog.require('ol.layer.Vector');
|
||||||
@@ -37,7 +38,7 @@ ol.layer.HeatmapLayerProperty = {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.layer.Heatmap = function(opt_options) {
|
ol.layer.Heatmap = function(opt_options) {
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var baseOptions = goog.object.clone(options);
|
var baseOptions = goog.object.clone(options);
|
||||||
|
|
||||||
@@ -58,7 +59,8 @@ ol.layer.Heatmap = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.shadow_ = goog.isDef(options.shadow) ? options.shadow : 250;
|
this.shadow_ = ol.isDef(options.shadow) ?
|
||||||
|
/** @type {number} */ (options.shadow) : 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -76,12 +78,14 @@ ol.layer.Heatmap = function(opt_options) {
|
|||||||
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT),
|
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT),
|
||||||
this.handleGradientChanged_, false, this);
|
this.handleGradientChanged_, false, this);
|
||||||
|
|
||||||
this.setGradient(goog.isDef(options.gradient) ?
|
this.setGradient(options.gradient ?
|
||||||
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
|
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
|
||||||
|
|
||||||
this.setBlur(goog.isDef(options.blur) ? options.blur : 15);
|
this.setBlur(ol.isDef(options.blur) ?
|
||||||
|
/** @type {number} */ (options.blur) : 15);
|
||||||
|
|
||||||
this.setRadius(goog.isDef(options.radius) ? options.radius : 8);
|
this.setRadius(ol.isDef(options.radius) ?
|
||||||
|
/** @type {number} */ (options.radius) : 8);
|
||||||
|
|
||||||
goog.events.listen(this, [
|
goog.events.listen(this, [
|
||||||
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR),
|
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR),
|
||||||
@@ -90,7 +94,7 @@ ol.layer.Heatmap = function(opt_options) {
|
|||||||
|
|
||||||
this.handleStyleChanged_();
|
this.handleStyleChanged_();
|
||||||
|
|
||||||
var weight = goog.isDef(options.weight) ? options.weight : 'weight';
|
var weight = options.weight ? options.weight : 'weight';
|
||||||
var weightFunction;
|
var weightFunction;
|
||||||
if (goog.isString(weight)) {
|
if (goog.isString(weight)) {
|
||||||
weightFunction = function(feature) {
|
weightFunction = function(feature) {
|
||||||
@@ -105,14 +109,15 @@ ol.layer.Heatmap = function(opt_options) {
|
|||||||
this.setStyle(goog.bind(function(feature, resolution) {
|
this.setStyle(goog.bind(function(feature, resolution) {
|
||||||
goog.asserts.assert(!goog.isNull(this.styleCache_),
|
goog.asserts.assert(!goog.isNull(this.styleCache_),
|
||||||
'this.styleCache_ should not be null');
|
'this.styleCache_ should not be null');
|
||||||
goog.asserts.assert(goog.isDef(this.circleImage_),
|
goog.asserts.assert(this.circleImage_ !== undefined,
|
||||||
'this.circleImage_ should be defined');
|
'this.circleImage_ should be defined');
|
||||||
var weight = weightFunction(feature);
|
var weight = weightFunction(feature);
|
||||||
var opacity = goog.isDef(weight) ? goog.math.clamp(weight, 0, 1) : 1;
|
var opacity = ol.isDef(weight) ?
|
||||||
|
goog.math.clamp(/** @type {number} */ (weight), 0, 1) : 1;
|
||||||
// cast to 8 bits
|
// cast to 8 bits
|
||||||
var index = (255 * opacity) | 0;
|
var index = (255 * opacity) | 0;
|
||||||
var style = this.styleCache_[index];
|
var style = this.styleCache_[index];
|
||||||
if (!goog.isDef(style)) {
|
if (!style) {
|
||||||
style = [
|
style = [
|
||||||
new ol.style.Style({
|
new ol.style.Style({
|
||||||
image: new ol.style.Icon({
|
image: new ol.style.Icon({
|
||||||
@@ -174,7 +179,7 @@ ol.layer.Heatmap.createGradient_ = function(colors) {
|
|||||||
ol.layer.Heatmap.prototype.createCircle_ = function() {
|
ol.layer.Heatmap.prototype.createCircle_ = function() {
|
||||||
var radius = this.getRadius();
|
var radius = this.getRadius();
|
||||||
var blur = this.getBlur();
|
var blur = this.getBlur();
|
||||||
goog.asserts.assert(goog.isDef(radius) && goog.isDef(blur),
|
goog.asserts.assert(radius !== undefined && blur !== undefined,
|
||||||
'radius and blur should be defined');
|
'radius and blur should be defined');
|
||||||
var halfSize = radius + blur + 1;
|
var halfSize = radius + blur + 1;
|
||||||
var size = 2 * halfSize;
|
var size = 2 * halfSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user