Giter Site home page Giter Site logo

Comments (5)

songyumeng avatar songyumeng commented on May 22, 2024

谢谢您再次提的issue,再次请您按照issue模板提issue,谢谢

from iclient-javascript.

songyumeng avatar songyumeng commented on May 22, 2024

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.

xiaogaofudao avatar xiaogaofudao commented on May 22, 2024

@songyumeng 非常感谢回答。
现在还有个问题请教,超图图层服务返回的geoJson x, y数据不是经纬度,而是两个数值都很大的值。
不能正确的渲染到 mapbox。在不改图层返回数据结果的情况下,有什么方法吗。
目前我想到的是遍历返回结果,转换成 经纬度,没有找到方法

from iclient-javascript.

songyumeng avatar songyumeng commented on May 22, 2024

这个现象引起的原因是,您的地图数据是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.

xiaogaofudao avatar xiaogaofudao commented on May 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.