报错
报indexOf undifend
您好,请把具体报错信息提供一下,但你的截图就是mapbox-gl-enhance.js里面的东西,这看不出具体的原因!
就是这个错
这个地址:
https://iclient.supermap.io/web/libs/mapbox-gl-js-enhance/1.2.0/mapbox-gl-enhance.js 顺便问一下非试用版的iclient怎么获取呀
这个js包和我本地的替换了,运行正常,iclient都是公开的,下载地址:https://iclient.supermap.io/download/download.html
下面是简单写的demo,地图是4490的,可以放进iclient的示例里面运行一下,放大缩小下地图,就会出现那个错误,地图上文字也不显示。 <!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_China2000"></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"> var host = window.isLocal ? window.server : 'http://iclient.supermap.io'; var url = host + '/iserver/services/map-china400/rest/maps/China_4490'; var map = new mapboxgl.Map({ container: 'map', // container id style: { version: 8, sources: { 'raster-tiles': { type: 'raster', tileSize: 256, tiles: [url], rasterSource: 'iserver' } }, layers: [ { id: 'simple-tiles', type: 'raster', source: 'raster-tiles', minzoom: 0, maxzoom: 22 } ] }, crs: 'EPSG:4490', center: [101.74721254733845, 32.5665352689922], zoom: 3 }); map.on('load', function () { map.loadImage( 'https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png', function (error, image) { if (error) throw error; map.addImage('custom-marker', image); map.addSource('points', { 'type': 'geojson', 'data': { 'type': 'FeatureCollection', 'features': [ { 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [ 120.5845575756689, 27.520996656654667 ] }, 'properties': { 'title': 'Mapbox DC' } }, { 'type': 'Feature', 'geometry': { 'type': 'Point', 'coordinates': [120.8845575756689, 27.520996656654667] }, 'properties': { 'title': 'Mapbox SF' } } ] } }); map.addLayer({ 'id': 'points', 'type': 'symbol', 'source': 'points', 'layout': { 'icon-image': 'custom-marker', 'text-field': ['get', 'title'], 'text-font': [ 'Open Sans Semibold', 'Arial Unicode MS Bold' ], 'text-offset': [0, 1.25], 'text-anchor': 'top' } }); } ); }); </script> </body> </html>