Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于中国居中版本 #14

Open
Happier-X opened this issue Sep 27, 2024 · 0 comments
Open

关于中国居中版本 #14

Happier-X opened this issue Sep 27, 2024 · 0 comments
Labels
question Further information is requested

Comments

@Happier-X
Copy link

在开发中客户提出让中国居中,目前我的解决思路是使用如下算法:

import worldJson from './world.zh.json'
// 对世界地图的json文件中的经纬度坐标进行处理
const process = item => {
    if (item > -30) {
        item = item - 180
    } else {
        item = item + 180
    }
    return item
}
// 格陵兰处理
const processGreenland = item => {
    return item + 180
}

worldJson.features.map((district, index) => {
    if (district.properties.name === '格陵兰') {
        if (district.geometry.type === 'Polygon') {
            district.geometry.coordinates.map(border => {
                border.map(coord => {
                    coord[0] = processGreenland(coord[0])
                })
            })
        } else {
            district.geometry.coordinates.map(border => {
                border.map(coordinates => {
                    coordinates.map(coord => {
                        coord[0] = processGreenland(coord[0])
                    })
                })
            })
        }
    } else {
        if (district.geometry.type == 'Polygon') {
            district.geometry.coordinates.map(border => {
                border.map(coord => {
                    coord[0] = process(coord[0])
                })
            })
        } else {
            district.geometry.coordinates.map(border => {
                border.map(coordinates => {
                    coordinates.map(coord => {
                        coord[0] = process(coord[0])
                    })
                })
            })
        }
    }
})
export default worldJson

现在有一个问题:南极洲部分我还没有想到合适的处理方式
因为客户没有要求显示南极洲,目前效果是这样的:
image

@Surbowl Surbowl added the documentation Improvements or additions to documentation label Sep 27, 2024
@Surbowl Surbowl added question Further information is requested and removed documentation Improvements or additions to documentation labels Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants