diff --git a/examples/geolocation.js b/examples/geolocation.js index 99b4fcfcdb..e3b1263130 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -37,9 +37,9 @@ geolocation.on('change', function() { }); var marker = new ol.Overlay({ - map: map, element: /** @type {Element} */ ($('').addClass('icon-flag').get(0)) }); +map.addOverlay(marker); // bind the marker position to the device location. marker.bindTo('position', geolocation); diff --git a/examples/icon.js b/examples/icon.js index a2c2918f55..071dd10a16 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -63,9 +63,9 @@ var map = new ol.Map({ var element = document.getElementById('popup'); var popup = new ol.Overlay({ - map: map, element: element }); +map.addOverlay(popup); map.on('click', function(evt) { diff --git a/examples/overlay.js b/examples/overlay.js index 8e44805f77..bd052fc983 100644 --- a/examples/overlay.js +++ b/examples/overlay.js @@ -24,17 +24,18 @@ var map = new ol.Map({ // Vienna label var vienna = new ol.Overlay({ - map: map, position: ol.proj.transform( [16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'), element: document.getElementById('vienna') }); +map.addOverlay(vienna); // Popup showing the position the user clicked var popup = new ol.Overlay({ - map: map, element: document.getElementById('popup') }); +map.addOverlay(popup); + map.on('click', function(evt) { var element = popup.getElement(); var coordinate = evt.getCoordinate(); diff --git a/examples/popup.js b/examples/popup.js index f291751b8b..bc002694c0 100644 --- a/examples/popup.js +++ b/examples/popup.js @@ -7,24 +7,6 @@ goog.require('ol.proj'); goog.require('ol.source.TileJSON'); -var layer = new ol.layer.TileLayer({ - source: new ol.source.TileJSON({ - url: 'http://api.tiles.mapbox.com/v3/' + - 'mapbox.natural-earth-hypso-bathy.jsonp', - crossOrigin: 'anonymous' - }) -}); - -var map = new ol.Map({ - layers: [layer], - target: 'map', - view: new ol.View2D({ - center: [0, 0], - zoom: 2 - }) -}); - - /** * Elements that make up the popup. */ @@ -48,11 +30,32 @@ closer.onclick = function() { * Create an overlay to anchor the popup to the map. */ var overlay = new ol.Overlay({ - map: map, element: container }); +/** + * Create the map. + */ +var map = new ol.Map({ + layers: [ + new ol.layer.TileLayer({ + source: new ol.source.TileJSON({ + url: 'http://api.tiles.mapbox.com/v3/' + + 'mapbox.natural-earth-hypso-bathy.jsonp', + crossOrigin: 'anonymous' + }) + }) + ], + overlays: [overlay], + target: 'map', + view: new ol.View2D({ + center: [0, 0], + zoom: 2 + }) +}); + + /** * Add a click handler to the map to render the popup. */ diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index e4ee31e3f1..84cac75b76 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -60,7 +60,6 @@ * Object literal with config options for the overlay. * @typedef {Object} ol.OverlayOptions * @property {Element|undefined} element The overlay element. - * @property {ol.Map|undefined} map The map to overlay onto. * @property {ol.Coordinate|undefined} position The overlay position in map * projection. * @property {ol.OverlayPositioning|undefined} positioning Positioning. diff --git a/src/ol/overlay.js b/src/ol/overlay.js index c7cfc15e9a..c232f1ed11 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -42,7 +42,6 @@ ol.OverlayPositioning = { * Example: * * var popup = new ol.Overlay({ - * map: map, * element: document.getElementById('popup') * }); * popup.setPosition(coordinate); @@ -110,9 +109,6 @@ ol.Overlay = function(options) { if (goog.isDef(options.positioning)) { this.setPositioning(options.positioning); } - if (goog.isDef(options.map)) { - this.setMap(options.map); - } }; goog.inherits(ol.Overlay, ol.Object);