首页 / 浏览问题 / WebGIS / 问题详情
mapboxgl 4326坐标系时,地图不能拖动位置的问题
14EXP 2022年12月23日

你好, 使用iclient for mapboxgl 4326坐标系时,地图不能拖动位置的问题。看上去像是被锁定在某一个位置了。请问是bug还是哪里传参的问题呢?

<!--********************************************************************
* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'/>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
    <title data-i18n="resources.title_tiledMapLayer"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div id='map'></div>
<script type="text/javascript" exclude='iclient-mapboxgl'  include="mapbox-gl-enhance" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
        " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
        " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";

     var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
            var url = host + '/iserver/services/map-china400/rest/maps/China_4326';
            var map = new mapboxgl.Map({
                container: 'map', // container id
                style: {
                    version: 8,
                    sources: {
                        'raster-tiles': {
                            type: 'raster',
                            tileSize: 256,
                            //xyz形式,原生支持
                            //"tiles": ['https://t0.tianditu.gov.cn/DataServer?T=vec_c&x={x}&y={y}&l={z}'],

                            //iserver image资源模板;扩展支持
                            //"tiles": ['http://localhost:8090/iserver/services/map-World/rest/maps/World/image.png?viewBounds={viewBounds}&width={width}&height={height}'],

                            //iserver tileimage资源模板;扩展支持
                            //"tiles": ['https://iserver.supermap.io/iserver/services/map-jingjin/rest/maps/%E4%BA%AC%E6%B4%A5%E5%9C%B0%E5%8C%BA%E5%9C%B0%E5%9B%BE/tileimage.png?scale={scale}&x={x}&y={y}&width={width}&height={height}&origin={"x":-180,"y":90}'],

                            //推荐;   iserver tileimage资源;扩展支持
                            //参数列表:
                            //地图服务地址(到地图名)必填 ;
                            //rasterSource为"iserver";必填;
                            //transparent:可选,默认为true;
                            //cacheEnabled: 是否使用缓存,默认为true;
                            //redirect: 如果为 true,则将请求重定向到瓦片的真实地址;如果为 false,则响应体中是瓦片的字节流,默认为false;
                            //layersID:要显示的图层id字符串;
                            //tileversion: 切片版本名称,cacheEnabled 为 true 时有效;
                            //rasterfunction: 栅格分析参数,类型为mapboxgl.supermap.NDVIParameter或mapboxgl.supermap.HillshadeParameter;
                            //format:瓦片格式,默认为'png';
                            tiles: [url],
                            rasterSource: 'iserver'
                        }
                    },

                    layers: [
                        {
                            id: 'simple-tiles',
                            type: 'raster',
                            source: 'raster-tiles',
                            minzoom: 0,
                            maxzoom: 22
                        }
                    ]
                },
                crs: 'EPSG:4326',
                center: [101.74721254733845, 32.5665352689922],
                zoom: 3,
                maxBounds:null
            });
  

</script>

</body>
</html>

1个回答

您好,您头文件的引用定义缺少了一些哦,

        <script
            type="text/javascript"
            include="mapbox-gl-enhance"
            src="../../dist/mapboxgl/include-mapboxgl.js"
        ></script>

希望可以帮助到您。
9,613EXP 2022年12月23日
<!--********************************************************************
* Copyright© 2000 - 2022 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'/>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
    <title data-i18n="resources.title_tiledMapLayer"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
    
    
            <script
            type="text/javascript"
            include="mapbox-gl-enhance"
            src="../../dist/mapboxgl/include-mapboxgl.js"
        ></script>
        
        
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div id='map'></div>
<script type="text/javascript" exclude='iclient-mapboxgl'  include="mapbox-gl-enhance" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
        " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
        " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";

     var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
            var url = host + '/iserver/services/map-china400/rest/maps/China_4326';
            var map = new mapboxgl.Map({
                container: 'map', // container id
                style: {
                    version: 8,
                    sources: {
                        'raster-tiles': {
                            type: 'raster',
                            tileSize: 256,
                            //xyz形式,原生支持
                            //"tiles": ['https://t0.tianditu.gov.cn/DataServer?T=vec_c&x={x}&y={y}&l={z}'],

                            //iserver image资源模板;扩展支持
                            //"tiles": ['http://localhost:8090/iserver/services/map-World/rest/maps/World/image.png?viewBounds={viewBounds}&width={width}&height={height}'],

                            //iserver tileimage资源模板;扩展支持
                            //"tiles": ['https://iserver.supermap.io/iserver/services/map-jingjin/rest/maps/%E4%BA%AC%E6%B4%A5%E5%9C%B0%E5%8C%BA%E5%9C%B0%E5%9B%BE/tileimage.png?scale={scale}&x={x}&y={y}&width={width}&height={height}&origin={"x":-180,"y":90}'],

                            //推荐;   iserver tileimage资源;扩展支持
                            //参数列表:
                            //地图服务地址(到地图名)必填 ;
                            //rasterSource为"iserver";必填;
                            //transparent:可选,默认为true;
                            //cacheEnabled: 是否使用缓存,默认为true;
                            //redirect: 如果为 true,则将请求重定向到瓦片的真实地址;如果为 false,则响应体中是瓦片的字节流,默认为false;
                            //layersID:要显示的图层id字符串;
                            //tileversion: 切片版本名称,cacheEnabled 为 true 时有效;
                            //rasterfunction: 栅格分析参数,类型为mapboxgl.supermap.NDVIParameter或mapboxgl.supermap.HillshadeParameter;
                            //format:瓦片格式,默认为'png';
                            tiles: [url],
                            rasterSource: 'iserver'
                        }
                    },

                    layers: [
                        {
                            id: 'simple-tiles',
                            type: 'raster',
                            source: 'raster-tiles',
                            minzoom: 0,
                            maxzoom: 22
                        }
                    ]
                },
                crs: 'EPSG:4326',
                center: [101.74721254733845, 32.5665352689922],
                zoom: 3,
                maxBounds:null
            });
 

</script>

</body>
</html>
...