Skip to content

Commit

Permalink
Merge pull request #4954 from camptocamp/GSGMF-1010
Browse files Browse the repository at this point in the history
Add back backgroundLayers options in the API
  • Loading branch information
fredj committed Jun 17, 2019
2 parents 2af895d + 768dcbf commit b1743e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/dist/apihelp/apihelp.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h2>A map with a marker on its center</h2>
var map = new demo.Map({
div: 'map2',
zoom: 8,
backgroundLayers: ['OSM map'],
center: [544500, 210100]
});
map.addMarker();
Expand Down
11 changes: 8 additions & 3 deletions api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class Map {
* @type {Overlay}
*/
this.overlay_ = new Overlay({
autoPan: true,
autoPanAnimation: {
duration: 80
},
element: this.createOverlayDomTree_()
});
this.map_.addOverlay(this.overlay_);
Expand Down Expand Up @@ -116,8 +120,10 @@ class Map {

// Get background layer first...
themes.getBackgroundLayers().then((layers) => {
// The options is an array for backward compatibility reason.
const backgroundLayer = options.backgroundLayers || [constants.backgroundLayer];
for (const layer of layers) {
if (layer.get('config.name') === constants.backgroundLayer) {
if (backgroundLayer.includes(layer.get('config.name'))) {
// we don't want the background layer in the layerswitch so we remove the title.
layer.set('title', undefined);
this.map_.addLayer(layer);
Expand Down Expand Up @@ -147,6 +153,7 @@ class Map {
*/
this.vectorLayer_ = new VectorLayer({
zIndex: 1,
style: null,
source: this.vectorSource_
});

Expand Down Expand Up @@ -359,7 +366,6 @@ class Map {
const content = this.overlay_.getElement().querySelector('.ol-popup-content');
content.innerHTML = contentHTML;
this.overlay_.setPosition(coordinates);
this.view_.setCenter(coordinates);
}
}

Expand All @@ -369,7 +375,6 @@ class Map {
clearSelection() {
// clear the selected features
this.selectInteraction_.getFeatures().clear();
this.vectorSource_.clear();
// hide the overlay
this.overlay_.setPosition(undefined);
}
Expand Down

0 comments on commit b1743e5

Please sign in to comment.