Skip to content

Commit

Permalink
Fix labels of geo3D, map3D. Fix #168
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Jan 23, 2018
1 parent 3b42ba4 commit 7b0f457
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions src/component/common/Geo3DBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ Geo3DBuilder.prototype = {
var height = distance;
if (coordSys.type === 'geo3D') {
var region = coordSys.getRegion(name);
if (!region) {
return [NaN, NaN, NaN];
}
center = region.center;
return coordSys.dataToPoint([center[0], center[1], height]);
var pos = coordSys.dataToPoint([center[0], center[1], height]);
return pos;
}
else {
var tmp = self._triangulationResults[dataIndex - self._startIndex];
Expand All @@ -129,16 +133,14 @@ Geo3DBuilder.prototype = {
},

_initMeshes: function () {
this.rootNode.removeAll();

var self = this;
function createPolygonMesh() {
var mesh = new graphicGL.Mesh({
name: 'Polygon',
material: new graphicGL.Material({
shader: self._shadersMap.lambert
}),
culling: false,
// culling: false,
geometry: new graphicGL.Geometry({
sortTriangles: true,
dynamic: true
Expand Down Expand Up @@ -345,30 +347,20 @@ Geo3DBuilder.prototype = {
if (dataIndex !== this._lastHoverDataIndex) {
this.downplay(this._lastHoverDataIndex);
this.highlight(dataIndex);

this._labelsBuilder.updateLabels([dataIndex]);
}
this._lastHoverDataIndex = dataIndex;
this._polygonMesh.dataIndex = dataIndex;
},

_onmouseover: function (e) {
if (e.target) {
var dataIndex = e.target.eventData
? this._data.indexOfName(e.target.eventData.name)
: e.target.dataIndex;
if (dataIndex != null) {
this.highlight(dataIndex);
this._labelsBuilder.updateLabels([dataIndex]);
}
}
},

_onmouseout: function (e) {
if (e.target) {
this.downplay(this._lastHoverDataIndex);
this._lastHoverDataIndex = -1;
this._polygonMesh.dataIndex = -1;
}

this._labelsBuilder.updateLabels([]);
},

_updateGroundPlane: function (componentModel, geo3D, api) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/LayerGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ LayerGL.prototype._dispatchDataEvent = function (eveName, originalEvent, newEven
eventProxy.dataIndex = dataIndex;
eventProxy.seriesIndex = seriesIndex;

if (eventData != null || parseInt(dataIndex, 10) >= 0) {
if (eventData != null || (parseInt(dataIndex, 10) >= 0 && parseInt(seriesIndex, 10) >= 0)) {
this.zr.handler.dispatchToElement(targetInfo, eveName, originalEvent);

if (elChangedInMouseMove) {
Expand Down

0 comments on commit 7b0f457

Please sign in to comment.