路径问题,仔细找过路径绝对是对的

0 投票
<!--********************************************************************
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title data-i18n="resources.title_getFeatureByBounds"></title>
    <style type="text/css">
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
        }

        #toolbar {
            position: absolute;
            top: 50px;
            right: 10px;
            text-align: center;
            z-index: 100;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div id="toolbar" class="panel panel-primary">
    <div class='panel-heading'>
        <h5 class='panel-title text-center' data-i18n="resources.title_getFeatureByBounds"></h5></div>
    <div class='panel-body content'>
        <input type="button" class="btn btn-default" data-i18n="[value]resources.text_query" onclick="draw()"/>&nbsp;
        <input type="button" class="btn btn-default" data-i18n="[value]resources.text_input_value_clear" onclick="clearFeatures()"/>
    </div>
</div>
<div id="map"></div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript"  src="../../dist/classic/include-classic.js"></script>
<script>
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var map, local, layer, vectorLayer, markerLayer, drawBounds,
        style = {
            strokeColor: "#304DBE",
            strokeWidth: 1,
            pointerEvents: "visiblePainted",
            fillColor: "#304DBE",
            fillOpacity: 0.5
        },
        url1 = host + "/iserver/services/map-world/rest/maps/World",
        url2 = host + "/iserver/services/data-world/rest/data";

    init();

    function init() {
        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");
        markerLayer = new SuperMap.Layer.Markers("Markers");

        drawBounds = new SuperMap.Control.DrawFeature(vectorLayer, SuperMap.Handler.Box);
        drawBounds.events.on({"featureadded": drawCompleted});
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                }),
                drawBounds]
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
    }

    function addLayer() {
        map.addLayers([layer, vectorLayer, markerLayer]);
        map.setCenter(new SuperMap.LonLat(0, 0), 0);
    }

    function draw() {
        widgets.alert.clearAlert();
        //先清除上次的显示结果
        vectorLayer.removeAllFeatures();
        markerLayer.clearMarkers();
        drawBounds.activate();
    }

    function drawCompleted(drawBoundsArgs) {
        var feature = drawBoundsArgs.feature;
        feature.style = style;
        vectorLayer.addFeatures(feature);
        var bounds = feature.geometry.bounds;
        //vectorLayer.removeAllFeatures();
        var GetFeaturesByBoundsParameters, getFeaturesByGeometryService;
        GetFeaturesByBoundsParameters = new SuperMap.REST.GetFeaturesByBoundsParameters({
            datasetNames: ["World:Capitals"],
            spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT,
            bounds: bounds
        });
        getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByBoundsService(url2, {
            eventListeners: {
                "processCompleted": processCompleted,
                "processFailed": processFailed
            }
        });
        getFeaturesByGeometryService.processAsync(GetFeaturesByBoundsParameters);
    }

    function processCompleted(getFeaturesEventArgs) {
        drawBounds.deactivate();
        var i, len, features, result = getFeaturesEventArgs.result;
        if (result && result.features) {
            features = result.features;
            for (i = 0, len = features.length; i < len; i++) {
                var point = features[i].geometry,
                    size = new SuperMap.Size(44, 33),
                    offset = new SuperMap.Pixel(-(size.w / 2), -size.h),
                    icon = new SuperMap.Icon("./images/marker.png", size, offset);
                markerLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon));
            }
        }
    }

    function processFailed(e) {
        widgets.alert.showAlert(e.error.errorMsg, false);
    }

    function clearFeatures() {
        widgets.alert.clearAlert();
        vectorLayer.removeAllFeatures();
        markerLayer.clearMarkers();
    }

</script>

</body>
</html>

supermap下载的资源包在exmaples里面原封不动的就能运行,换个位置就不行了。里面的引入文件的路径 无论是觉得还是相当都改过了 就是找不到某些 

10月 28, 2020 分类:  141次浏览 | 用户: 木大木大 初出茅庐 (43 分)

1个回答

0 投票

你好,您可以使用在线资源https://iclient.supermap.io/web/libs/iclient8c/libs/SuperMap.Include.js以及https://iclient.supermap.io/dist/classic/iclient-classic.js

10月 28, 2020 用户: weizhonrun 名扬四海 (1,130 分)
...