Remove map from OverlayOptions
This commit is contained in:
@@ -37,9 +37,9 @@ geolocation.on('change', function() {
|
||||
});
|
||||
|
||||
var marker = new ol.Overlay({
|
||||
map: map,
|
||||
element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0))
|
||||
});
|
||||
map.addOverlay(marker);
|
||||
// bind the marker position to the device location.
|
||||
marker.bindTo('position', geolocation);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user