Skip to content

Commit

Permalink
update 动态标记图层增加修改图层名 review by luox
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Nov 10, 2023
1 parent f56210d commit 47eb8f6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export default class AnimateMarkerLayerViewModel extends mapboxgl.Evented {
this._initalizeMarkerLayer(fitBounds);
}

public setLayerId(layerId) {
if (!this.features || JSON.stringify(this.features) === '{}') {
return;
}
this.removed();
this.layerId = layerId;
this._createMarker();
}

private _initalizeMarkerLayer(fitBounds?) {
if (!this.features || JSON.stringify(this.features) === '{}') {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,38 @@ describe('AnimateMarkerLayer.vue', () => {
expect(wrapper.vm.viewModel.layerId).toBe('test-id');
done();
});

it('change layerId', async done => {
const newFeatures= {
features: [
{
geometry: {
type: 'Point',
coordinates: [122, 53]
},
properties: {
SmID: '10'
},
type: 'Feature'
}
],
type: 'FeatureCollection'
};
wrapper = mount(SmAnimateMarkerLayer, {
propsData: {
features: newFeatures,
mapTarget: 'map',
textField: 'name',
layerId: 'test-id1'
}
});
const spy = jest.spyOn(wrapper.vm.viewModel, 'setLayerId');
await mapSubComponentLoaded(wrapper);
await wrapper.setProps({
layerId: 'test-id2'
});
expect(spy).toHaveBeenCalled();
expect(wrapper.vm.viewModel.layerId).toBe('test-id2');
done();
});
});

0 comments on commit 47eb8f6

Please sign in to comment.