Merge pull request #431 from twpayne/rename-anchoredelement-to-overlay

Rename AnchoredElement to Overlay
This commit is contained in:
Tom Payne
2013-03-25 03:36:57 -07:00
7 changed files with 86 additions and 87 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
goog.require('ol.AnchoredElement');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Geolocation'); goog.require('ol.Geolocation');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
@@ -25,7 +25,7 @@ var map = new ol.Map({
var geolocation = new ol.Geolocation(); var geolocation = new ol.Geolocation();
geolocation.bindTo('projection', map.getView()); geolocation.bindTo('projection', map.getView());
var marker = new ol.AnchoredElement({ var marker = new ol.Overlay({
map: map, map: map,
element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0)) element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0))
}); });
@@ -62,7 +62,7 @@
margin-left: -13px; margin-left: -13px;
} }
</style> </style>
<title>Anchored elements example</title> <title>Overlay example</title>
</head> </head>
<body> <body>
@@ -91,12 +91,12 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span4"> <div class="span4">
<h4 id="title">Anchored elements example</h4> <h4 id="title">Overlay example</h4>
<p id="shortdesc">Demonstrates anchored elements.</p> <p id="shortdesc">Demonstrates overlays.</p>
<div id="docs"> <div id="docs">
<p>See the <a href="anchored-elements.js" target="_blank">anchored-elements.js source</a> to see how this is done.</p> <p>See the <a href="overlay.js" target="_blank">overlay.js source</a> to see how this is done.</p>
</div> </div>
<div id="tags">anchored elements, overlay, popup, mapquest, openaerial</div> <div id="tags">overlay, popup, mapquest, openaerial</div>
</div> </div>
</div> </div>
@@ -110,7 +110,7 @@
<div class="overlay arrow_box" id="popup"></div> <div class="overlay arrow_box" id="popup"></div>
</div> </div>
<script src="loader.js?id=anchored-elements" type="text/javascript"></script> <script src="loader.js?id=overlay" type="text/javascript"></script>
<script src="social-links.js" type="text/javascript"></script> <script src="social-links.js" type="text/javascript"></script>
</body> </body>
@@ -1,6 +1,6 @@
goog.require('ol.AnchoredElement');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.Overlay');
goog.require('ol.RendererHints'); goog.require('ol.RendererHints');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.layer.TileLayer'); goog.require('ol.layer.TileLayer');
@@ -23,7 +23,7 @@ var map = new ol.Map({
}); });
// Vienna label // Vienna label
var vienna = new ol.AnchoredElement({ var vienna = new ol.Overlay({
map: map, map: map,
position: ol.projection.transform( position: ol.projection.transform(
new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'), new ol.Coordinate(16.3725, 48.208889), 'EPSG:4326', 'EPSG:3857'),
@@ -31,7 +31,7 @@ var vienna = new ol.AnchoredElement({
}); });
// Popup showing the position the user clicked // Popup showing the position the user clicked
var popup = new ol.AnchoredElement({ var popup = new ol.Overlay({
map: map, map: map,
element: document.getElementById('popup') element: document.getElementById('popup')
}); });
+5 -5
View File
@@ -106,11 +106,11 @@
@exportObjectLiteralProperty ol.layer.VectorLayerOptions.style ol.style.Style|undefined @exportObjectLiteralProperty ol.layer.VectorLayerOptions.style ol.style.Style|undefined
@exportObjectLiteralProperty ol.layer.VectorLayerOptions.visible boolean|undefined @exportObjectLiteralProperty ol.layer.VectorLayerOptions.visible boolean|undefined
@exportObjectLiteral ol.AnchoredElementOptions @exportObjectLiteral ol.OverlayOptions
@exportObjectLiteralProperty ol.AnchoredElementOptions.element Element|undefined @exportObjectLiteralProperty ol.OverlayOptions.element Element|undefined
@exportObjectLiteralProperty ol.AnchoredElementOptions.map ol.Map|undefined @exportObjectLiteralProperty ol.OverlayOptions.map ol.Map|undefined
@exportObjectLiteralProperty ol.AnchoredElementOptions.position ol.Coordinate|undefined @exportObjectLiteralProperty ol.OverlayOptions.position ol.Coordinate|undefined
@exportObjectLiteralProperty ol.AnchoredElementOptions.positioning ol.AnchoredElementPositioning|undefined @exportObjectLiteralProperty ol.OverlayOptions.positioning ol.OverlayPositioning|undefined
@exportObjectLiteral ol.source.BingMapsOptions @exportObjectLiteral ol.source.BingMapsOptions
@exportObjectLiteralProperty ol.source.BingMapsOptions.culture string|undefined @exportObjectLiteralProperty ol.source.BingMapsOptions.culture string|undefined
-7
View File
@@ -1,7 +0,0 @@
@exportClass ol.AnchoredElement ol.AnchoredElementOptions
@exportSymbol ol.AnchoredElementPositioning
@exportProperty ol.AnchoredElementPositioning.BOTTOM_LEFT
@exportProperty ol.AnchoredElementPositioning.BOTTOM_RIGHT
@exportProperty ol.AnchoredElementPositioning.TOP_LEFT
@exportProperty ol.AnchoredElementPositioning.TOP_RIGHT
+7
View File
@@ -0,0 +1,7 @@
@exportClass ol.Overlay ol.OverlayOptions
@exportSymbol ol.OverlayPositioning
@exportProperty ol.OverlayPositioning.BOTTOM_LEFT
@exportProperty ol.OverlayPositioning.BOTTOM_RIGHT
@exportProperty ol.OverlayPositioning.TOP_LEFT
@exportProperty ol.OverlayPositioning.TOP_RIGHT
+63 -64
View File
@@ -1,6 +1,6 @@
goog.provide('ol.AnchoredElement'); goog.provide('ol.Overlay');
goog.provide('ol.AnchoredElementPositioning'); goog.provide('ol.OverlayPositioning');
goog.provide('ol.AnchoredElementProperty'); goog.provide('ol.OverlayProperty');
goog.require('goog.dom'); goog.require('goog.dom');
goog.require('goog.events'); goog.require('goog.events');
@@ -14,7 +14,7 @@ goog.require('ol.Object');
/** /**
* @enum {string} * @enum {string}
*/ */
ol.AnchoredElementProperty = { ol.OverlayProperty = {
ELEMENT: 'element', ELEMENT: 'element',
MAP: 'map', MAP: 'map',
POSITION: 'position', POSITION: 'position',
@@ -25,7 +25,7 @@ ol.AnchoredElementProperty = {
/** /**
* @enum {string} * @enum {string}
*/ */
ol.AnchoredElementPositioning = { ol.OverlayPositioning = {
BOTTOM_LEFT: 'bottom-left', BOTTOM_LEFT: 'bottom-left',
BOTTOM_RIGHT: 'bottom-right', BOTTOM_RIGHT: 'bottom-right',
TOP_LEFT: 'top-left', TOP_LEFT: 'top-left',
@@ -37,10 +37,9 @@ ol.AnchoredElementPositioning = {
/** /**
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @param {ol.AnchoredElementOptions} anchoredElementOptions Anchored element * @param {ol.OverlayOptions} options Options.
* options.
*/ */
ol.AnchoredElement = function(anchoredElementOptions) { ol.Overlay = function(options) {
goog.base(this); goog.base(this);
@@ -68,95 +67,95 @@ ol.AnchoredElement = function(anchoredElementOptions) {
}; };
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.AnchoredElementProperty.ELEMENT), this, ol.Object.getChangedEventType(ol.OverlayProperty.ELEMENT),
this.handleElementChanged, false, this); this.handleElementChanged, false, this);
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.AnchoredElementProperty.MAP), this, ol.Object.getChangedEventType(ol.OverlayProperty.MAP),
this.handleMapChanged, false, this); this.handleMapChanged, false, this);
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.AnchoredElementProperty.POSITION), this, ol.Object.getChangedEventType(ol.OverlayProperty.POSITION),
this.handlePositionChanged, false, this); this.handlePositionChanged, false, this);
goog.events.listen( goog.events.listen(
this, this,
ol.Object.getChangedEventType(ol.AnchoredElementProperty.POSITIONING), ol.Object.getChangedEventType(ol.OverlayProperty.POSITIONING),
this.handlePositioningChanged, false, this); this.handlePositioningChanged, false, this);
if (goog.isDef(anchoredElementOptions.element)) { if (goog.isDef(options.element)) {
this.setElement(anchoredElementOptions.element); this.setElement(options.element);
} }
if (goog.isDef(anchoredElementOptions.position)) { if (goog.isDef(options.position)) {
this.setPosition(anchoredElementOptions.position); this.setPosition(options.position);
} }
if (goog.isDef(anchoredElementOptions.positioning)) { if (goog.isDef(options.positioning)) {
this.setPositioning(anchoredElementOptions.positioning); this.setPositioning(options.positioning);
} }
if (goog.isDef(anchoredElementOptions.map)) { if (goog.isDef(options.map)) {
this.setMap(anchoredElementOptions.map); this.setMap(options.map);
} }
}; };
goog.inherits(ol.AnchoredElement, ol.Object); goog.inherits(ol.Overlay, ol.Object);
/** /**
* @return {Element|undefined} Element. * @return {Element|undefined} Element.
*/ */
ol.AnchoredElement.prototype.getElement = function() { ol.Overlay.prototype.getElement = function() {
return /** @type {Element|undefined} */ ( return /** @type {Element|undefined} */ (
this.get(ol.AnchoredElementProperty.ELEMENT)); this.get(ol.OverlayProperty.ELEMENT));
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'getElement', 'getElement',
ol.AnchoredElement.prototype.getElement); ol.Overlay.prototype.getElement);
/** /**
* @return {ol.Map|undefined} Map. * @return {ol.Map|undefined} Map.
*/ */
ol.AnchoredElement.prototype.getMap = function() { ol.Overlay.prototype.getMap = function() {
return /** @type {ol.Map|undefined} */ ( return /** @type {ol.Map|undefined} */ (
this.get(ol.AnchoredElementProperty.MAP)); this.get(ol.OverlayProperty.MAP));
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'getMap', 'getMap',
ol.AnchoredElement.prototype.getMap); ol.Overlay.prototype.getMap);
/** /**
* @return {ol.Coordinate|undefined} Position. * @return {ol.Coordinate|undefined} Position.
*/ */
ol.AnchoredElement.prototype.getPosition = function() { ol.Overlay.prototype.getPosition = function() {
return /** @type {ol.Coordinate|undefined} */ ( return /** @type {ol.Coordinate|undefined} */ (
this.get(ol.AnchoredElementProperty.POSITION)); this.get(ol.OverlayProperty.POSITION));
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'getPosition', 'getPosition',
ol.AnchoredElement.prototype.getPosition); ol.Overlay.prototype.getPosition);
/** /**
* @return {ol.AnchoredElementPositioning|undefined} Positioning. * @return {ol.OverlayPositioning|undefined} Positioning.
*/ */
ol.AnchoredElement.prototype.getPositioning = function() { ol.Overlay.prototype.getPositioning = function() {
return /** @type {ol.AnchoredElementPositioning|undefined} */ ( return /** @type {ol.OverlayPositioning|undefined} */ (
this.get(ol.AnchoredElementProperty.POSITIONING)); this.get(ol.OverlayProperty.POSITIONING));
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'getPositioning', 'getPositioning',
ol.AnchoredElement.prototype.getPositioning); ol.Overlay.prototype.getPositioning);
/** /**
* @protected * @protected
*/ */
ol.AnchoredElement.prototype.handleElementChanged = function() { ol.Overlay.prototype.handleElementChanged = function() {
goog.dom.removeChildren(this.element_); goog.dom.removeChildren(this.element_);
var element = this.getElement(); var element = this.getElement();
if (goog.isDefAndNotNull(element)) { if (goog.isDefAndNotNull(element)) {
@@ -168,7 +167,7 @@ ol.AnchoredElement.prototype.handleElementChanged = function() {
/** /**
* @protected * @protected
*/ */
ol.AnchoredElement.prototype.handleMapChanged = function() { ol.Overlay.prototype.handleMapChanged = function() {
if (!goog.isNull(this.mapPostrenderListenerKey_)) { if (!goog.isNull(this.mapPostrenderListenerKey_)) {
goog.dom.removeNode(this.element_); goog.dom.removeNode(this.element_);
goog.events.unlistenByKey(this.mapPostrenderListenerKey_); goog.events.unlistenByKey(this.mapPostrenderListenerKey_);
@@ -188,7 +187,7 @@ ol.AnchoredElement.prototype.handleMapChanged = function() {
/** /**
* @protected * @protected
*/ */
ol.AnchoredElement.prototype.handleMapPostrender = function() { ol.Overlay.prototype.handleMapPostrender = function() {
this.updatePixelPosition_(); this.updatePixelPosition_();
}; };
@@ -196,7 +195,7 @@ ol.AnchoredElement.prototype.handleMapPostrender = function() {
/** /**
* @protected * @protected
*/ */
ol.AnchoredElement.prototype.handlePositionChanged = function() { ol.Overlay.prototype.handlePositionChanged = function() {
this.updatePixelPosition_(); this.updatePixelPosition_();
}; };
@@ -204,7 +203,7 @@ ol.AnchoredElement.prototype.handlePositionChanged = function() {
/** /**
* @protected * @protected
*/ */
ol.AnchoredElement.prototype.handlePositioningChanged = function() { ol.Overlay.prototype.handlePositioningChanged = function() {
this.updatePixelPosition_(); this.updatePixelPosition_();
}; };
@@ -212,51 +211,51 @@ ol.AnchoredElement.prototype.handlePositioningChanged = function() {
/** /**
* @param {Element|undefined} element Element. * @param {Element|undefined} element Element.
*/ */
ol.AnchoredElement.prototype.setElement = function(element) { ol.Overlay.prototype.setElement = function(element) {
this.set(ol.AnchoredElementProperty.ELEMENT, element); this.set(ol.OverlayProperty.ELEMENT, element);
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'setElement', 'setElement',
ol.AnchoredElement.prototype.setElement); ol.Overlay.prototype.setElement);
/** /**
* @param {ol.Map|undefined} map Map. * @param {ol.Map|undefined} map Map.
*/ */
ol.AnchoredElement.prototype.setMap = function(map) { ol.Overlay.prototype.setMap = function(map) {
this.set(ol.AnchoredElementProperty.MAP, map); this.set(ol.OverlayProperty.MAP, map);
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'setMap', 'setMap',
ol.AnchoredElement.prototype.setMap); ol.Overlay.prototype.setMap);
/** /**
* @param {ol.Coordinate|undefined} position Position. * @param {ol.Coordinate|undefined} position Position.
*/ */
ol.AnchoredElement.prototype.setPosition = function(position) { ol.Overlay.prototype.setPosition = function(position) {
this.set(ol.AnchoredElementProperty.POSITION, position); this.set(ol.OverlayProperty.POSITION, position);
}; };
goog.exportProperty( goog.exportProperty(
ol.AnchoredElement.prototype, ol.Overlay.prototype,
'setPosition', 'setPosition',
ol.AnchoredElement.prototype.setPosition); ol.Overlay.prototype.setPosition);
/** /**
* @param {ol.AnchoredElementPositioning|undefined} positioning Positioning. * @param {ol.OverlayPositioning|undefined} positioning Positioning.
*/ */
ol.AnchoredElement.prototype.setPositioning = function(positioning) { ol.Overlay.prototype.setPositioning = function(positioning) {
this.set(ol.AnchoredElementProperty.POSITIONING, positioning); this.set(ol.OverlayProperty.POSITIONING, positioning);
}; };
/** /**
* @private * @private
*/ */
ol.AnchoredElement.prototype.updatePixelPosition_ = function() { ol.Overlay.prototype.updatePixelPosition_ = function() {
var map = this.getMap(); var map = this.getMap();
var position = this.getPosition(); var position = this.getPosition();
@@ -273,8 +272,8 @@ ol.AnchoredElement.prototype.updatePixelPosition_ = function() {
goog.asserts.assert(goog.isDef(mapSize)); goog.asserts.assert(goog.isDef(mapSize));
var style = this.element_.style; var style = this.element_.style;
var positioning = this.getPositioning(); var positioning = this.getPositioning();
if (positioning == ol.AnchoredElementPositioning.BOTTOM_RIGHT || if (positioning == ol.OverlayPositioning.BOTTOM_RIGHT ||
positioning == ol.AnchoredElementPositioning.TOP_RIGHT) { positioning == ol.OverlayPositioning.TOP_RIGHT) {
if (this.rendered_.left_ !== '') { if (this.rendered_.left_ !== '') {
this.rendered_.left_ = style.left = ''; this.rendered_.left_ = style.left = '';
} }
@@ -291,8 +290,8 @@ ol.AnchoredElement.prototype.updatePixelPosition_ = function() {
this.rendered_.left_ = style.left = left; this.rendered_.left_ = style.left = left;
} }
} }
if (positioning == ol.AnchoredElementPositioning.TOP_LEFT || if (positioning == ol.OverlayPositioning.TOP_LEFT ||
positioning == ol.AnchoredElementPositioning.TOP_RIGHT) { positioning == ol.OverlayPositioning.TOP_RIGHT) {
if (this.rendered_.bottom_ !== '') { if (this.rendered_.bottom_ !== '') {
this.rendered_.bottom_ = style.bottom = ''; this.rendered_.bottom_ = style.bottom = '';
} }