Skip to content

Commit

Permalink
Set the position to undefined to hide the overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Jan 6, 2015
1 parent 06fe828 commit d4ff552
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion examples/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
<style type="text/css">
.ol-popup {
display: none;
position: absolute;
background-color: white;
-moz-box-shadow: 0 1px 4px rgba(0,0,0,0.2);
Expand Down
6 changes: 2 additions & 4 deletions examples/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var closer = document.getElementById('popup-closer');
* @return {boolean} Don't follow the href.
*/
closer.onclick = function() {
container.style.display = 'none';
overlay.setPosition(undefined);
closer.blur();
return false;
};
Expand Down Expand Up @@ -65,9 +65,7 @@ map.on('click', function(evt) {
var hdms = ol.coordinate.toStringHDMS(ol.proj.transform(
coordinate, 'EPSG:3857', 'EPSG:4326'));

overlay.setPosition(coordinate);
content.innerHTML = '<p>You clicked here:</p><code>' + hdms +
'</code>';
container.style.display = 'block';

overlay.setPosition(coordinate);
});
3 changes: 2 additions & 1 deletion src/ol/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ goog.exportProperty(


/**
* Set the position for this overlay.
* Set the position for this overlay. If the position is `undefined` the
* overlay is hidden.
* @param {ol.Coordinate|undefined} position The spatial point that the overlay
* is anchored at.
* @observable
Expand Down

0 comments on commit d4ff552

Please sign in to comment.