查询结果定位和高亮显示

0 投票
1.查询对象是三维管线符号化的矢量数据,设置查询结果高亮用的示例“查询服务”的方法:

       resulstStyle3D.set_lineColor(new SuperMap.Web.Core.Color(218, 29, 29, 1));
        resulstStyle3D.set_fillForeColor(new SuperMap.Web.Core.Color(218, 29, 29, 1));
        resulstStyle3D.set_markerColor(new SuperMap.Web.Core.Color(218, 29, 29, 1));
        resulstStyle3D.set_lineWidth(5);
        resulstStyle3D.set_markerSize(10);
        feature3D.set_style3D(resulstStyle3D);

但是没有显示高亮,是不是因为管线实际上是模型符号而不行呢?

2.查询结果定位用一下方法能否实现呢?

feature3Ds = new SuperMap.Web.Core.Feature3Ds();

feature3Ds.add(feature3D);

scene.get_flyingOperator().flyTo(feature3Ds.get_camera());
11月 24, 2016 分类:  2426次浏览 | 用户: Lavone 初出茅庐 (21 分)

1个回答

0 投票

你好,范例是把对象显示出来加到跟踪层了。简单直接一点的做法是把查询结果直接加到选择集。

建议你看一下这篇交流:

http://qa.supermap.com/619/swcjzrhsxglxs.html.

定位的话,建议是

sceneControl.get_scene().get_flyingOperator().flyToBounds(bounds, -1);
11月 24, 2016 用户: 邹涛 名扬四海 (3,389 分)
修改于 11月 24, 2016 用户:邹涛
你好,建议用sceneControl.get_scene().get_flyingOperator().flyToBounds(bounds, -1);
但是好像只能获取到layer的bounds,怎么获取查询结果集的bounds呢?
viewBounds = new SuperMap.Bounds();
var layer3D = scene.get_layer3Ds().get_item(queryDatasetName + "@" + dataSource); // 改为你的图层名称
resultFeatures = queryEventArgs.originResult.features;
// 遍历查询结果
for (var m = 0; m < resultFeatures.length; m++)
{
    var feature2D = resultFeatures[m];
    feature2Ds.append(feature2D);
    var id=feature2D.ID;
    layer3D.get_selection3D().add(id);
    var geoVector = feature2D.geometry;
    var geoType = geoVector.type;
    var dz = 0;
    switch (geoType)
    {
        case "POINT3D":
            break;
        case "LINE3D":
            break;
        case "REGION":
            var geoRegion3D = new SuperMap.Web.Core.GeoRegion3D();
            var pt3Ds = new SuperMap.Web.Core.Point3Ds();
            var pt3D = new SuperMap.Web.Core.Point3D(0,0,0);
            for (var j = 0; j < geoVector.points.length; j++)
            {
                pt3D.x = geoVector.points[j].x;
                pt3D.y = geoVector.points[j].y;
                pt3D.z = 0;
                pt3Ds.add(pt3D);
            }
            geoRegion3D.addPart(pt3Ds);
            left = geoRegion3D.get_boundingBox().get_lower().get_x();
            bottom = geoRegion3D.get_boundingBox().get_lower().get_y();
            right = geoRegion3D.get_boundingBox().get_upper().get_x();
            top = geoRegion3D.get_boundingBox().get_upper().get_y();
            viewBounds.extend(new SuperMap.Bounds(left, bottom, right, top));
            upper = geoRegion3D.get_boundingBox().get_upper().get_z();
            dz = dz > upper ? dz : upper;
            break;
        case "GEOMODEL":
            var left = geoVector.boundingBox.lower.x;
            var bottom = geoVector.boundingBox.lower.y;
            var right = geoVector.boundingBox.upper.x;
            var top = geoVector.boundingBox.upper.y;
            viewBounds.extend(new SuperMap.Bounds(left, bottom, right, top));
            upper = geoVector.boundingBox.upper.z;
            dz = dz > upper ? dz : upper;
            break;
    }
    /*var feature3d = new SuperMap.Web.Core.Feature3D();
    feature3d.set_geometry(feature2D.geometry);
    var featureBounds = feature3d.get_bounds();*/
}
/* ---------------------------------------- */
/* 调整相机到合适位置.                      */
/* ---------------------------------------- */
var altitude = calculateAltitudeFromBounds(viewBounds) + dz;
var camera = sceneControl.get_scene().get_camera();
var centerLonLat = viewBounds.getCenterLonLat();
var lookAt =new SuperMap.Web.Realspace.LookAt(centerLonLat.lon, centerLonLat.lat, altitude);
lookAt.set_tilt(camera.get_tilt());
lookAt.set_heading(camera.get_heading());
sceneControl.get_scene().get_flyingOperator().flyToLookAt(lookAt, 2000);
或者直接飞到bounds
sceneControl.get_scene().get_flyingOperator().flyToBounds(viewBounds, 2000);
function calculateAltitudeFromBounds(bounds)
{
    var _PI = 3.1415926;
    var _earthRadius = 6378137;
    var altitude = _earthRadius;
    var boundsWidth = bounds.right - bounds.left;
    if (boundsWidth >= 120) {
        altitude = _earthRadius * boundsWidth / 60 - _earthRadius;
    }
    else if (boundsWidth != 0) {
        var angle1 = (boundsWidth / 360) * _PI;
        var height = Math.sin(angle1) * _earthRadius;
        var a = height / Math.tan(angle1);
        var b = height / Math.tan(_PI / 6);
        altitude = a + b - _earthRadius;
    }
    return altitude;
}
...