首页 / 浏览问题 / 云GIS / 问题详情
代码没问题那会是浏览器的问题呢?
6EXP 2017年05月12日

谢谢您的指导,那就奇怪了,没这边点击按钮激活之后,每点击一次,就结束上一条线立刻出来新的一条线。

难道是浏览器的问题?  我在360和IE上都是一个效果的。。。。

1个回答

您好!这个应该不是浏览器的问题,我这边没有360,用IE测试也是可以的,你那边是用谷歌或者火狐测试可以,ie和360不行吗?
663EXP 2017年05月12日

这是我用你的代码,换成我本地的服务,改了之前给你说的那几个细节,要不你用我的代码试一下。不行的话,你私信我一下你的QQ,我远程给你看一下

<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>SuperMap iClient for JavaScript:TiledDynamicRESTLayer</title>
    <script src='./libs/SuperMap.Include.js'></script>
    <script type="text/javascript">

        var map, layer, lineLayer, drawLine;
        //var url = "http://localhost:8090/iserver/services/map-World/rest/maps/World_Image";
       // url =  "http://localhost:8090/iserver/services/map-world/rest/maps/World";
        url =  "http://localhost:8090/iserver/services/map-world/rest/maps/世界地图_Day";
        var style = {
            strokeColor:"#red",
            strokeWidth:2,
            pointerEvents:"visiblePainted",
            fillColor:"red",
            fillOpacity:0.8
        }
        function onPageLond() {
            /*--------------------------------------------矢量图层-------------------------------------------*/
            lineLayer = new SuperMap.Layer.Vector("lineLayer");
            //创建绘制线段的控件
            drawLine = new SuperMap.Control.DrawFeature(lineLayer, SuperMap.Handler.Path,{multi:true});
            //设置绘制线段控件的监听事件
            drawLine.events.on( {"featureadded":drawCompleted} );


            /*--------------------------------------------地图图层-------------------------------------------*/
            map = new SuperMap.Map('map',{controls:[
                        new SuperMap.Control.PanZoomBar(),
                        new SuperMap.Control.ScaleLine(),
                        new SuperMap.Control.LayerSwitcher(),
                        drawLine
                    ]}
            );
//            layer = new SuperMap.Layer.TiledDynamicRESTLayer(
//                    "World_Image",
//                    url,
//                    {transparent:true, cacheEnabled:true},
//                    {maxResolution:"auto", scales:[1/150000000]}
//            );
            layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {transparent: true, cacheEnabled: true}, {maxResolution:"auto"});
            layer.events.on({"layerInitialized": addLayer});
        }
        function addLayer() {
            var objs = [layer,lineLayer];
            map.addLayers(objs);
            map.setCenter(new SuperMap.LonLat(0, 0), 0);
        }
        function drawCompleted(arguments) {
            drawLine.deactivate();
            //获取绘制的线段
            var geometry = arguments.feature.geometry;
            var parameters = new SuperMap.REST.MeasureParameters(geometry);

            //交互
            var measureService = new SuperMap.REST.MeasureService(
                    url,
                    {
                        measureMode: SuperMap.REST.MeasureMode.DISTANCE,
                        eventListeners:{
                            "processCompleted":measureCompleted,
                            "processFailed":measureFailed
                        }
                    }
            );
            measureService.processAsync(parameters);
        }
        function measureCompleted(arguments) {
            if(arguments.result.distance != -1) {
                alert(arguments.result.distance);
            } else {
                alert("没距离");
            }
        }
        function measureFailed(arguments) {
            alert(arguments.error);
        }

        function distanceMeasure() {
            lineLayer.removeAllFeatures();
            drawLine.activate();
        }
    </script>
</head>

<body onload="onPageLond()">
<div id="map" style="position:relative; left:0px; right:0px; width:1000px;height:500px;" >
</div>
<form id="f1">
    <input id="t1" type="button" value="绘制测量" onclick="distanceMeasure()" />
</form>
</body>
</html>

找到问题了,特幼稚的"中文;"问题,一直没发现,谢谢,谢谢
您好!不好意思啊,三维的产品我不负责支持,你可以再提一个问题,会有三维的同事帮你解答的,或者是您也可以拨打我们的技术支持电话4008900866,选择三维产品咨询!
好好好,谢谢
...