Merge pull request #22 from antvis/readme

更新地图样式
This commit is contained in:
@thinkinggis 2019-09-02 16:44:19 +08:00 committed by GitHub
commit 966b6aeccd
6 changed files with 128 additions and 10 deletions

2
.gitignore vendored
View File

@ -78,4 +78,4 @@ lib
webpack-dev.config.js
webpack.config.js
.si.yml
git_log.sh
git_log.sh

82
.npmignore Normal file
View File

@ -0,0 +1,82 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# lock
package-lock.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.DS_Store
# npmignore - content above this line is automatically generated and modifications may be omitted
# see npmjs.com/npmignore for more details.
test
*.sw*
*.un~
.idea
bin
bundler
demos
docs
src
temp
webpack-dev.config.js
webpack.config.js
testdemo
rollup
.si.yml

View File

@ -1,10 +1,8 @@
{
"name": "@antv/l7",
"version": "1.3.2",
"version": "1.3.3-beta.1",
"description": "Large-scale WebGL-powered Geospatial Data Visualization",
"main": "build/L7.js",
"browser": "build/L7-min.js",
"module": "lib/index.js",
"homepage": "https://github.com/antvis/l7",
"repository": {
"type": "git",
@ -47,7 +45,7 @@
"open": "~6.4.0",
"parseurl": "~1.3.2",
"postcss-url": "^8.0.0",
"pre-commit": "~1.2.2",
"pre-commit": "^1.2.2",
"rollup": "^1.16.2",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.2.1",
@ -57,6 +55,7 @@
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^4.0.4",
"serve-static": "^1.13.2",
"shelljs": "~0.7.8",
@ -67,7 +66,7 @@
"scripts": {
"build-dev": "rollup -c --environment BUILD:dev",
"watch-dev": "rollup -c --environment BUILD:dev --watch & npm run demos-web ",
"build-prod": "rollup -c --environment BUILD:production",
"build-prod": "rollup -c --environment BUILD",
"build-prod-min": "rollup -c --environment BUILD:production,MINIFY:true",
"build": "rollup -c --environment BUILD:production",
"build-lib": "babel src --out-dir lib",
@ -83,11 +82,11 @@
"demos": "electron ./demos/app.js",
"demos-web": "node ./demos/app.js --web --port 2046",
"dev": "npm run watch & npm run demos-web",
"dist": "npm run build-dev && npm run build-prod && npm run build-prod-min",
"dist": "npm run build-prod && npm run build-prod-min",
"lint": "eslint --ext .html,.js ./",
"lint-fix": "eslint --ext .html,.js --fix ./",
"mkdir-dist": "node ./bin/mkdir-dist.js",
"prepublishOnly": "npm run build-lib && npm run dist",
"prepublishOnly": "npm run dist",
"screenshot": "node ./bin/screenshot.js",
"start": "npm run watch-dev",
"test": "torch --compile-opts ./.torch.compile.opts.js --compile --renderer --recursive test/unit",
@ -106,7 +105,6 @@
"silent": false
},
"dependencies": {
"@antv/g": "^3.1.3",
"@antv/geo-coord": "^1.0.8",
"@antv/util": "~2.0.1",
"@mapbox/geojson-rewind": "^0.4.0",

View File

@ -1,4 +1,5 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import json from 'rollup-plugin-json';
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
@ -74,7 +75,7 @@ const config = [
},
treeshake: false,
plugins: [
// css()
sourcemaps()
]
}
];

View File

@ -130,6 +130,13 @@ export default class Scene extends Base {
getMarkerContainer() {
return this._markerContainier;
}
map2Png() {
this.scene._engine.update();
const vis = this.scene._engine._renderer.domElement.toDataURL();
const map = this.scene.map.getContainer().getElementsByClassName('amap-layer')[0].toDataURL();
return [ map, vis ];
}
_registEvents() {
const events = [
'mouseout',

View File

@ -42,6 +42,9 @@ export default class GaodeMap extends Base {
case 'light':
this.set('mapStyle', Theme.LightTheme.mapStyle);
break;
case 'blank':
this.set('mapStyle', 'blank');
break;
default:
this.set('mapStyle', mapStyle);
}
@ -52,11 +55,17 @@ export default class GaodeMap extends Base {
this.map = map;
this.container = map.getContainer();
this.get('mapStyle') && this.map.setMapStyle(this.get('mapStyle'));
if (this.get('mapStyle') === 'blank') {
map.setFeatures([]);
}
this.addOverLayer();
setTimeout(() => { this.emit('mapLoad'); }, 50);
} else {
this.map = new AMap.Map(this.container, this._attrs);
this.map.on('complete', () => {
if (this.get('mapStyle') === 'blank') {
map.setFeatures([]);
}
this.addOverLayer();
this.emit('mapLoad');
});
@ -143,10 +152,31 @@ export default class GaodeMap extends Base {
scene.getBounds = () => {
return map.getBounds();
};
scene.setMapStyle = style => {
switch (style) {
case 'dark':
this.set('mapStyle', Theme.DarkTheme.mapStyle);
break;
case 'light':
this.set('mapStyle', Theme.LightTheme.mapStyle);
break;
default:
this.set('mapStyle', style);
}
map.setMapStyle(this.get('mapStyle'));
if (style === 'blank') {
map.setFeatures([]);
}
return;
};
scene.setZoomAndCenter = (zoom, center) => {
const lnglat = new AMap.LngLat(center[0], center[1]);
return map.setZoomAndCenter(zoom, lnglat);
};
scene.setFeature = features => {
return map.setFeature(features);
};
scene.setBounds = extent => {
return map.setBounds(new AMap.Bounds([ extent[0], extent[1] ], [ extent[2], extent[3] ]));
};