Skip to content

Commit

Permalink
fix(webmap): hide the rest when base layer showing
Browse files Browse the repository at this point in the history
  • Loading branch information
rendrom committed Sep 21, 2021
1 parent 6e7a5f3 commit 4cd3950
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/cancelable-promise/src/PromiseControl.ts
Expand Up @@ -50,7 +50,7 @@ export class PromiseControl {
if (this.isLoaded) {
this._promises.forEach((x) => {
if (x.cancel) {
x.cancel();
x.cancel()
}
});
this._promises.clear();
Expand Down
23 changes: 2 additions & 21 deletions packages/vue-ngw-map/src/components/VueNgwMapNew.ts
@@ -1,27 +1,8 @@
import Vue, { VNode, VNodeData, CreateElement } from 'vue';
// import { Prop, Vue } from 'vue-property-decorator';
// import Component from 'vue-class-component';
import { MapAdapter } from '@nextgis/webmap';
import { NgwMap, NgwMapOptions } from '@nextgis/ngw-map';

import NgwConnector from '@nextgis/ngw-connector';
import { NgwMap} from '@nextgis/ngw-map';
import type { VueNgwMapData, VueNgwMapProps } from '../interfaces';

export interface VueNgwMapData<M = any> {
ngwMap: NgwMap<M>;
ready: boolean;
}

// interface Methods {}
// interface Computed {}
export interface VueNgwMapProps {
mapAdapter: MapAdapter;
fullFilling: boolean;
connector: NgwConnector;
baseUrl: string;
qmsId: string;
webMapId: string;
mapOptions: NgwMapOptions;
}

export const VueNgwMap = Vue.extend<VueNgwMapData, any, any, VueNgwMapProps>({
props: {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-ngw-map/src/index.ts
@@ -1,4 +1,4 @@
import { VueNgwMapData, VueNgwMapProps } from './components/VueNgwMapNew';
import type { VueNgwMapData, VueNgwMapProps } from './interfaces';

export type { VueNgwMapData, VueNgwMapProps };

Expand Down
21 changes: 21 additions & 0 deletions packages/vue-ngw-map/src/interfaces.ts
@@ -0,0 +1,21 @@
import { MapAdapter } from '@nextgis/webmap';
import { NgwMap, NgwMapOptions } from '@nextgis/ngw-map';

import NgwConnector from '@nextgis/ngw-connector';

export interface VueNgwMapData<M = any> {
ngwMap: NgwMap<M>;
ready: boolean;
}

// interface Methods {}
// interface Computed {}
export interface VueNgwMapProps {
mapAdapter: MapAdapter;
fullFilling: boolean;
connector: NgwConnector;
baseUrl: string;
qmsId: string;
webMapId: string;
mapOptions: NgwMapOptions;
}
19 changes: 9 additions & 10 deletions packages/webmap/src/WebMapLayers.ts
Expand Up @@ -42,7 +42,7 @@ export class WebMapLayers<
M = any,
L = any,
E extends WebMapEvents = WebMapEvents,
O extends MapOptions = MapOptions,
O extends MapOptions = MapOptions
> extends WebMapMain<M, E, O> {
private _layersIdCounter = 1;
private _layersOrderCounter = 1;
Expand Down Expand Up @@ -169,7 +169,7 @@ export class WebMapLayers<
*/
async addBaseLayer<
K extends keyof LayerAdapters,
O extends AdapterOptions = AdapterOptions,
O extends AdapterOptions = AdapterOptions
>(
adapter: K | Type<LayerAdapters[K]>,
options?: O | LayerAdaptersOptions[K],
Expand Down Expand Up @@ -202,7 +202,7 @@ export class WebMapLayers<
*/
async addLayer<
K extends keyof LayerAdapters,
LO extends AdapterOptions = AdapterOptions,
LO extends AdapterOptions = AdapterOptions
>(
adapter: LayerAdapterDefinition<K>,
options: LO | LayerAdaptersOptions[K] = {},
Expand Down Expand Up @@ -333,7 +333,7 @@ export class WebMapLayers<

async addLayerFromAsyncAdapter<
K extends keyof LayerAdapters,
O extends AdapterOptions = AdapterOptions,
O extends AdapterOptions = AdapterOptions
>(
adapter: AdapterConstructor,
options: O | LayerAdaptersOptions[K],
Expand Down Expand Up @@ -447,7 +447,7 @@ export class WebMapLayers<
*/
addGeoJsonLayer<
K extends keyof LayerAdapters = keyof LayerAdapters,
O extends GeoJsonAdapterOptions<any, any> = GeoJsonAdapterOptions,
O extends GeoJsonAdapterOptions<any, any> = GeoJsonAdapterOptions
>(
opt: O = {} as O,
adapter?: LayerAdapterDefinition<K>,
Expand All @@ -471,7 +471,7 @@ export class WebMapLayers<
G extends Geometry = Geometry,
O extends GeoJsonAdapterOptions<Feature<G, P>> = GeoJsonAdapterOptions<
Feature<G, P>
>,
>
>(options = {} as O): Promise<FeatureLayerAdapter<P, G>> {
return this.addGeoJsonLayer<'GEOJSON', O>(options) as Promise<
FeatureLayerAdapter<P, G>
Expand Down Expand Up @@ -554,14 +554,13 @@ export class WebMapLayers<

// do not show baselayer if another on the map
if (l.options.baselayer && this._baselayers.length) {
const anotherVisibleLayerBaseLayer = this._baselayers.find((x) => {
const anotherVisibleBaselayers = this._baselayers.filter((x) => {
return x !== l.id && this.isLayerVisible(x);
});
if (anotherVisibleLayerBaseLayer) {
await this.hideLayer(anotherVisibleLayerBaseLayer);
for (const bl of anotherVisibleBaselayers) {
await this.hideLayer(bl);
}
}

if (l.showLayer) {
l.showLayer.call(l, l.layer);
} else if (l.layer !== undefined) {
Expand Down

0 comments on commit 4cd3950

Please sign in to comment.