Shared module for map event type enum

This commit is contained in:
Tim Schaub
2016-12-27 13:52:02 -07:00
parent c6c105b62f
commit 3fd88b3a22
6 changed files with 33 additions and 32 deletions

View File

@@ -1,10 +1,10 @@
goog.provide('ol.control.Control');
goog.require('ol.events');
goog.require('ol');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.Object');
goog.require('ol.dom');
goog.require('ol.events');
/**
@@ -118,7 +118,7 @@ ol.control.Control.prototype.setMap = function(map) {
target.appendChild(this.element);
if (this.render !== ol.nullFunction) {
this.listenerKeys.push(ol.events.listen(map,
ol.MapEvent.Type.POSTRENDER, this.render, this));
ol.MapEventType.POSTRENDER, this.render, this));
}
map.render();
}

View File

@@ -3,7 +3,7 @@ goog.provide('ol.control.OverviewMap');
goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.Map');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.MapProperty');
goog.require('ol.Object');
goog.require('ol.Overlay');
@@ -443,7 +443,7 @@ ol.control.OverviewMap.prototype.handleToggle_ = function() {
if (!this.collapsed_ && !ovmap.isRendered()) {
ovmap.updateSize();
this.resetExtent_();
ol.events.listenOnce(ovmap, ol.MapEvent.Type.POSTRENDER,
ol.events.listenOnce(ovmap, ol.MapEventType.POSTRENDER,
function(event) {
this.updateBox_();
},

View File

@@ -8,9 +8,10 @@ goog.require('ol');
goog.require('ol.Collection');
goog.require('ol.CollectionEventType');
goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapBrowserEventHandler');
goog.require('ol.MapBrowserEventType');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.MapProperty');
goog.require('ol.Object');
goog.require('ol.TileQueue');
@@ -1288,13 +1289,13 @@ ol.Map.prototype.renderFrame_ = function(time) {
if (idle) {
this.dispatchEvent(
new ol.MapEvent(ol.MapEvent.Type.MOVEEND, this, frameState));
new ol.MapEvent(ol.MapEventType.MOVEEND, this, frameState));
ol.extent.clone(frameState.extent, this.previousExtent_);
}
}
this.dispatchEvent(
new ol.MapEvent(ol.MapEvent.Type.POSTRENDER, this, frameState));
new ol.MapEvent(ol.MapEventType.POSTRENDER, this, frameState));
setTimeout(this.handlePostRender.bind(this), 0);

View File

@@ -36,25 +36,3 @@ ol.MapEvent = function(type, map, opt_frameState) {
};
ol.inherits(ol.MapEvent, ol.events.Event);
/**
* @enum {string}
*/
ol.MapEvent.Type = {
/**
* Triggered after a map frame is rendered.
* @event ol.MapEvent#postrender
* @api
*/
POSTRENDER: 'postrender',
/**
* Triggered after the map is moved.
* @event ol.MapEvent#moveend
* @api stable
*/
MOVEEND: 'moveend'
};

22
src/ol/mapeventtype.js Normal file
View File

@@ -0,0 +1,22 @@
goog.provide('ol.MapEventType');
/**
* @enum {string}
*/
ol.MapEventType = {
/**
* Triggered after a map frame is rendered.
* @event ol.MapEvent#postrender
* @api
*/
POSTRENDER: 'postrender',
/**
* Triggered after the map is moved.
* @event ol.MapEvent#moveend
* @api stable
*/
MOVEEND: 'moveend'
};

View File

@@ -1,7 +1,7 @@
goog.provide('ol.Overlay');
goog.require('ol');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.Object');
goog.require('ol.dom');
goog.require('ol.events');
@@ -236,7 +236,7 @@ ol.Overlay.prototype.handleMapChanged = function() {
var map = this.getMap();
if (map) {
this.mapPostrenderListenerKey_ = ol.events.listen(map,
ol.MapEvent.Type.POSTRENDER, this.render, this);
ol.MapEventType.POSTRENDER, this.render, this);
this.updatePixelPosition();
var container = this.stopEvent_ ?
map.getOverlayContainerStopEvent() : map.getOverlayContainer();