You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/06/10 15:02:17 UTC

[GitHub] [incubator-echarts] liiiku commented on issue #3899: 世界地图的视图中心点可以定制吗

liiiku commented on issue #3899: 世界地图的视图中心点可以定制吗
URL: https://github.com/apache/incubator-echarts/issues/3899#issuecomment-500449883
 
 
   将以非洲为中心的geojson改成以亚洲为中心的geojson,方法如下:
   
   ```
   // 对纬度进行偏移
   const processLng = lng => {
       return lng > -30 ? lng - 150 : lng + 210
   }
   
   //引入世界地图
   import worldMap from '../data/world.json'
   
   const coordinatesList = []
   
   // 对世界地图的json文件中的经纬度坐标进行处理
   worldMap.features.map(district => {
       if (district.geometry.type == 'Polygon') {
         district.geometry.coordinates.map(border => {
           border.map(coord => {
             coord[0] = processLng(coord[0])
             coordinatesList.push(coord)
           })
         })
     } else {
         district.geometry.coordinates.map(border => {
           border.map(coordinates => {
             coordinates.map(coord => {
               coord[0] = processLng(coord[0])
               coordinatesList.push(coord)
             })
           })
         })
       }
     })
   ```
   这样世界地图的效果变成了期望的效果:
   ![world](https://user-images.githubusercontent.com/21993582/59204674-b3a7f500-8bd3-11e9-9f90-48a05e4d2a4d.jpg)
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org