首页 / 浏览问题 / 云GIS / 问题详情
SQL查询F12报错
24EXP 2018年07月27日

我无法使用自己发布的rest数据服务,然后用超图自带的example SQL查询 rest数据服务是可以的,但是就算是超图的 我用console(sqlParam);   console( resultLayer);查看属性,F12报错,说是sqlParam没有被定义? Uncaught ReferenceError: sqlParam is not defined

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>数据集SQL查询</title>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="dist/include-leaflet.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
    var map, resultLayer,
        baseUrl = host + "/iserver/services/map-world/rest/maps/World",
        url = host + "/iserver/services/data-world/rest/data";
    map = L.map('map', {
        preferCanvas: true,
        crs: L.CRS.EPSG4326,
        center: {lon: 0, lat: 0},
        maxZoom: 18,
        zoom: 1
    });
    L.supermap.tiledMapLayer(baseUrl).addTo(map);
    query();

    function query() {
        var sqlParam = new SuperMap.GetFeaturesBySQLParameters({
            queryParameter: {
                name: "Countries@World",
                attributeFilter: "SMID = 247"
            },
            datasetNames: ["World:Countries"]
        });
        L.supermap
            .featureService(url)
            .getFeaturesBySQL(sqlParam, function (serviceResult) {
                resultLayer = L.geoJSON(serviceResult.result.features).addTo(map).bindPopup('SMID = 247');
            });
    };
 console(sqlParam);
 console( resultLayer);
 
</script>
</body>
</html>

1个回答

您好,应该是用console.log(),而且里面的sqlParam是局部变量,不能写在外面
5,668EXP 2018年07月27日
...