首页 / 浏览问题 / 云GIS / 问题详情
sql查询无法高亮显示
5EXP 2018年07月26日
sql查询自己的图层数据信息无法正常高亮显示,请求大神帮助

1个回答

您好,能提供一下源码吗?
于浩
1
5,668EXP 2018年07月26日

源码就是iclient自带examples里的示例。

<!DOCTYPE>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>SQL 查询</title>
        <style type="text/css">
            body{
                margin: 0;
                overflow: hidden;
                background: #fff;
            }
            #map{
                position: relative;
                height: 510px;
                border:1px solid #3473b7;
            }
            #toolbar {
                position: relative;
                padding-top: 5px;
                padding-bottom: 10px;
            }
        </style>
        <link href='./css/bootstrap.min.css' rel='stylesheet' />
        <link href='./css/bootstrap-responsive.min.css' rel='stylesheet' />
        <script src='../libs/SuperMap.Include.js'></script>
        <script type="text/javascript">
            var host = document.location.toString().match(/file:\/\//)?"http://localhost:8090":'http://' + document.location.host;
            var map, local, layer, vectorLayer
            style = {
                strokeColor: "#304DBE",
                strokeWidth: 1,
                fillColor: "#304DBE",
                fillOpacity: "0.8"
            },
            url1=host + "/iserver/services/map-xxx/rest/maps/xxxxxx",
            url2=host + "/iserver/services/data-xxx/rest/data";
            function init(){
                map = new SuperMap.Map("map",{controls: [
                    new SuperMap.Control.LayerSwitcher(),
                    new SuperMap.Control.ScaleLine(),
                    new SuperMap.Control.Zoom(),
                    new SuperMap.Control.Navigation({
                        dragPanOptions: {
                            enableKinetic: true
                        }
                    })]
                });
                layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url1, {transparent: true, cacheEnabled: true}, {maxResolution:"auto"});
                layer.events.on({"layerInitialized":addLayer});
                vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
            }

            function addLayer() {
                map.addLayers([layer, vectorLayer]);
                map.setCenter(new SuperMap.LonLat(119.4, 30.36), 12);
            }
            function getFeaturesBySQL() {
                vectorLayer.removeAllFeatures();

                var getFeatureParam, getFeatureBySQLService, getFeatureBySQLParams;

                getFeatureParam = new SuperMap.REST.FilterParameter({
                    name: "数据集@数据源",
                    attributeFilter: "SMID = 1"
                });
                getFeatureBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({
                    queryParameter: getFeatureParam,
                    datasetNames:["数据源:数据集"]
                });
                getFeatureBySQLService = new SuperMap.REST.GetFeaturesBySQLService(url2, {
                    eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}});

                getFeatureBySQLService.processAsync(getFeatureBySQLParams);
            }
            function processCompleted(getFeaturesEventArgs) {
                var i, len, features, feature, result = getFeaturesEventArgs.result;
                if (result && result.features) {
                    features = result.features
                    for (i=0, len=features.length; i<len; i++) {
                        feature = features[i];
                        feature.style = style;
                        vectorLayer.addFeatures(feature);
                    }
                }
            }
            function processFailed(e) {
                alert(e.error.errorMsg);
            }
            function clearFeatures() {
                //先清除上次的显示结果
                vectorLayer.removeAllFeatures();
                vectorLayer.refresh();
            }
        </script>
    </head>
    <body onload="init()">
        <div id="toolbar">
            <input type="button" class="btn" value="查询" onclick="getFeaturesBySQL()" />
            <input type="button" class="btn" value="清除" onclick="clearFeatures()" />
        </div>
        <div id="map"></div>
    </body>
</html>

您可以看一下浏览器报错,按F12
浏览器没有报错
已经成功解决了!感谢!
请问是怎么解决的呀?
...