fix setmapStyle

add blank theme
This commit is contained in:
thinkinggis 2019-09-12 10:28:34 +08:00
parent 33274bf610
commit ded4fee6c5
5 changed files with 20 additions and 10 deletions

View File

@ -92,7 +92,7 @@ scene.on('loaded', () => {
.render();
setTimeout(()=>{
scene.destroy();
scene.setMapStyle('grey');
},2000)
});

View File

@ -23,6 +23,7 @@ export default class Popup extends Base {
this._scene.on('click', this._onClickClose);
}, 30);
}
return this;
}
setLnglat(lngLat) {
this.lngLat = lngLat;

View File

@ -38,13 +38,13 @@ export default class GaodeMap extends Base {
if (mapStyle) {
switch (mapStyle) {
case 'dark':
this.set('mapStyle', Theme.DarkTheme.mapStyle);
this.set('mapStyle', Theme.darkTheme.mapStyle);
break;
case 'light':
this.set('mapStyle', Theme.LightTheme.mapStyle);
this.set('mapStyle', Theme.lightTheme.mapStyle);
break;
case 'blank':
this.set('mapStyle', 'blank');
this.set('mapStyle', Theme.blankTheme.mapStyle);
break;
default:
this.set('mapStyle', mapStyle);
@ -122,10 +122,13 @@ export default class GaodeMap extends Base {
const map = this.map;
switch (style) {
case 'dark':
this.set('mapStyle', Theme.DarkTheme.mapStyle);
this.set('mapStyle', Theme.darkTheme.mapStyle);
break;
case 'light':
this.set('mapStyle', Theme.LightTheme.mapStyle);
this.set('mapStyle', Theme.lightTheme.mapStyle);
break;
case 'blank':
this.set('mapStyle', Theme.blankTheme.mapStyle);
break;
default:
this.set('mapStyle', style);
@ -134,7 +137,8 @@ export default class GaodeMap extends Base {
map.setMapStyle(this.get('mapStyle'));
if (style === 'blank') {
map.setFeatures([]);
} else {
} else
if (map.getFeatures().length === 0) {
map.setFeatures(defaultMapFeatures);
}
return;

4
src/theme/blank.js Normal file
View File

@ -0,0 +1,4 @@
const BlankTheme = {
mapStyle: 'amap://styles/07c17002b38775b32a7a76c66cf90e99?isPublic=true'
};
export default BlankTheme;

View File

@ -1,3 +1,4 @@
import DarkTheme from './dark';
import LightTheme from './light';
export { DarkTheme, LightTheme };
import darkTheme from './dark';
import lightTheme from './light';
import blankTheme from './blank';
export { darkTheme, lightTheme, blankTheme };