+
+
+
+
+
+
+
+
+
diff --git a/demos/tile.html b/demos/tile.html
new file mode 100644
index 0000000000..f0867c42a7
--- /dev/null
+++ b/demos/tile.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
hexagon demo
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/scene.js b/src/core/scene.js
index 1309cfd525..0789516806 100644
--- a/src/core/scene.js
+++ b/src/core/scene.js
@@ -39,7 +39,7 @@ export default class Scene extends Base {
const MapProvider = getMap(this.mapType);
const Map = new MapProvider(this._attrs);
Map.mixMap(this);
- this._container = document.getElementById(Map.container);
+ this._container = Map.container;
// const Map = new MapProvider(this.mapContainer, this._attrs);
Map.on('mapLoad', () => {
this.map = Map.map;
diff --git a/src/geom/material/tile/polygon.js b/src/geom/material/tile/polygon.js
new file mode 100644
index 0000000000..ca385261bc
--- /dev/null
+++ b/src/geom/material/tile/polygon.js
@@ -0,0 +1,28 @@
+import Material from '../material';
+import { getModule } from '../../../util/shaderModule';
+export default class TileMaterial extends Material {
+ getDefaultParameters() {
+ return {
+ uniforms: {
+ u_opacity: { value: 1.0 },
+ u_time: { value: 0 },
+ u_activeId: { value: 0 },
+ u_activeColor: { value: [ 1.0, 0, 0, 1.0 ] }
+ },
+ defines: {
+
+ }
+ };
+ }
+ constructor(_uniforms, _defines, parameters) {
+ super(parameters);
+ const { uniforms, defines } = this.getDefaultParameters();
+ const { vs, fs } = getModule('tilepolygon');
+ this.uniforms = Object.assign(uniforms, this.setUniform(_uniforms));
+ this.type = 'tile_polygon_Material';
+ this.defines = Object.assign(defines, _defines);
+ this.vertexShader = vs;
+ this.fragmentShader = fs;
+ this.transparent = true;
+ }
+}
diff --git a/src/geom/shader/tile/polygon_frag.glsl b/src/geom/shader/tile/polygon_frag.glsl
new file mode 100644
index 0000000000..1093800cbc
--- /dev/null
+++ b/src/geom/shader/tile/polygon_frag.glsl
@@ -0,0 +1,5 @@
+
+varying vec4 v_color;
+void main(){
+ gl_FragColor = v_color;
+}
\ No newline at end of file
diff --git a/src/geom/shader/tile/polygon_vert.glsl b/src/geom/shader/tile/polygon_vert.glsl
new file mode 100644
index 0000000000..a25b39a653
--- /dev/null
+++ b/src/geom/shader/tile/polygon_vert.glsl
@@ -0,0 +1,17 @@
+
+attribute vec4 a_color;
+uniform float u_zoom;
+uniform float u_opacity;
+varying vec4 v_color;
+uniform float u_activeId;
+uniform vec4 u_activeColor;
+void main(){
+ mat4 matModelViewProjection=projectionMatrix*modelViewMatrix;
+ v_color=a_color;
+ v_color.a*=u_opacity;
+ if(pickingId==u_activeId){
+ v_color = u_activeColor;
+ }
+ gl_Position=projectionMatrix*vec4(position.xy / 4096.,0.,1.);
+
+}
\ No newline at end of file
diff --git a/src/map/AMap.js b/src/map/AMap.js
index c4ba78e2a5..8ac662f838 100644
--- a/src/map/AMap.js
+++ b/src/map/AMap.js
@@ -28,7 +28,7 @@ export default class GaodeMap extends Base {
}
constructor(cfg) {
super(cfg);
- this.container = this.get('id');
+ this.container = document.getElementById(this.get('id'));
this.initMap();
this.addOverLayer();
setTimeout(() => {
@@ -38,7 +38,6 @@ export default class GaodeMap extends Base {
initMap() {
const mapStyle = this.get('mapStyle');
-
switch (mapStyle) {
case 'dark':
this.set('mapStyle', Theme.DarkTheme.mapStyle);
@@ -50,7 +49,14 @@ export default class GaodeMap extends Base {
this.set('mapStyle', mapStyle);
}
this.set('zooms', [ this.get('minZoom'), this.get('maxZoom') ]);
- this.map = new AMap.Map(this.container, this._attrs);
+ const map = this.get('map');
+ if (map instanceof AMap.Map) {
+ this.map = map;
+ this.container = map.getContainer();
+ this.map.setMapStyle(this.get('mapStyle'));
+ } else {
+ this.map = new AMap.Map(this.container, this._attrs);
+ }
}
asyncCamera(engine) {
this._engine = engine;
@@ -74,10 +80,6 @@ export default class GaodeMap extends Base {
camera.lookAt(0, 0, 0);
camera.position.x += e.camera.position.x;
camera.position.y += -e.camera.position.y;
- // scene.position.x = -e.camera.position.x;
- // scene.position.y = e.camera.position.y;
- // pickScene.position.x = -e.camera.position.x;
- // pickScene.position.y = e.camera.position.y;
});
}
@@ -91,7 +93,7 @@ export default class GaodeMap extends Base {
return this.projectFlat(this.getCenter());
}
addOverLayer() {
- const canvasContainer = document.getElementById(this.container);
+ const canvasContainer = this.container instanceof HTMLElement ? this.container : document.getElementById(this.container);
this.canvasContainer = canvasContainer;
this.renderDom = document.createElement('div');
this.renderDom.style.cssText +=