Comments (5)
谢谢您再次提的issue,再次请您按照issue模板提issue,谢谢
from iclient-javascript.
GetFeaturesBySQLService回来的要素可以通过mapboxgl的geojsonlayer把要素上在图上。
geojsonlayer的color参数支持mapboxgl的expressions,比如这个场景可以使用expressions-match
maoboxgl官网例子地址:https://docs.mapbox.com/mapbox-gl-js/example/data-driven-circle-colors/
相关例子还有很多,可以在mapboxgl官方例子上搜索 color
expressions
等关键字学习。
from iclient-javascript.
@songyumeng 非常感谢回答。
现在还有个问题请教,超图图层服务返回的geoJson x, y数据不是经纬度,而是两个数值都很大的值。
不能正确的渲染到 mapbox。在不改图层返回数据结果的情况下,有什么方法吗。
目前我想到的是遍历返回结果,转换成 经纬度,没有找到方法
from iclient-javascript.
这个现象引起的原因是,您的地图数据是Web Mercator(3857)或者其他投影坐标系的,所以查询出来的结果也是米制坐标的,而mapboxgl期望的叠加数据是经纬度坐标(地理坐标)。
目前无论是mapboxgl还是iclient-mapboxgl,都没有提供现成的投影转换接口。
这个的问题的解决办法暂时有两个:
1,如果您使用的是工作空间数据,可以使用SuperMap iDesktop 软件将数据集转换为WGS84(4326)坐标系,但注意保持地图仍然是Web Mercator(3857),再使用mapboxgl.supermap.FeatureService(dataUrl).getFeaturesByXX相关方法查询要素
2,使用proj4库在前端遍历返回结果坐标转换proj4('EPSG:3857', 'EPSG:4326', [x, y])
,类似这个例子http://iclient.supermap.io/examples/mapboxgl/editor.html#04_surfaceAnalystService
也可以寻找是否有geojson相关坐标转换的库,这样可以对整个要素进行坐标转换,不用自己遍历。
后期iclient-mapboxgl会考虑提供坐标转换接口。
from iclient-javascript.
@songyumeng 多谢。网上找到了转换方法,测试可用
//经纬度转web墨卡托
lonLat2WebMercator(lng, lat) {
var x = (lng * 20037508.34) / 180;
var ly =
Math.log(Math.tan(((90 + lat) * Math.PI) / 360)) / (Math.PI / 180);
var y = (ly * 20037508.34) / 180;
return [x, y];
},
//web墨卡托转经纬度
WebMercator2lonLat(x, y) {
var lng = (x / 20037508.34) * 180;
var lata = (y / 20037508.34) * 180;
var lat =
(180 / Math.PI) *
(2 * Math.atan(Math.exp((lata * Math.PI) / 180)) - Math.PI / 2);
return [lng, lat];
}
from iclient-javascript.
Related Issues (20)
- 如何在小程序中使用? HOT 1
- Vue+@supermap/iclient-ol加载矢量瓦片报错 HOT 1
- 项目中引入proj4leaflet后再引入这个包会报错No projection definition for code EPSG:4490 HOT 3
- iclient-mapboxgl使用4490坐标系, toThreeMesh转一个多边形时,位置与实际位置偏移 HOT 1
- classic地图点击事件无效 HOT 1
- vite开发,控制台报错 HOT 1
- iclient-ol建议把ol-mapbox-style作为模块引入
- 根据官网案例创建WMTS时报错,Uncaught TypeError: layer.getLayerStatesArray is not a function HOT 1
- 不兼容Openlayers7 HOT 2
- 能否兼容Echarts5.x版本 HOT 1
- 请问支持离线地图么 HOT 1
- React的文档有么? HOT 1
- 包里面echart 报错 (急急急急急急急) HOT 3
- 【bug】官网示例报错 editor.html:46 Uncaught TypeError: mapboxgl.CRS is not a constructor HOT 5
- BUG:@supermap/iclient-common 包依赖echarts4.x版本但是package.json中没有声明该依赖 HOT 3
- 【bug】mapbox版本引入增强包后,maxBounds 参数失效 HOT 3
- 升级到 11.1.0报错 HOT 9
- 升级到 11.1.0-a 报错
- 11.1.1版本 node_modules包里面的flatgeobuf 文件2.23.1版本js文件大小写不匹配冲突 HOT 3
- TypeScript support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iclient-javascript.