fix setmapStyle

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

View File

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

View File

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

View File

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