maptalks/examples

优化identify代码

Closed this issue · 1 comments

现有的代码

function getPickedCoordinate(coordinate) {
      const identifyData = groupLayer.identify(coordinate)[0];
      const pickedPoint = identifyData && identifyData.point;
      if (pickedPoint) {
        const altitude = map_talk.pointAtResToAltitude(pickedPoint[2], map_talk.getGLRes());
        const coordinate = map_talk.pointAtResToCoordinate(new maptalks.Point(pickedPoint[0], pickedPoint[1]), map_talk.getGLRes());
        return new maptalks.Coordinate(coordinate.x, coordinate.y, altitude);
      }else {
          coordinate['z']=0;
          return coordinate;
        }
    }

改为以下的形式

const identifyData = groupLayer.identify(coordinate)[0];
return identifyData && identifyData.coordinate;