D3墨卡托功能NaN [英] D3 mercator function NaN

查看:270
本文介绍了D3墨卡托功能NaN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对D3墨卡托投影功能不太熟悉,并且得到了一些意想不到的结果.我想预测以下经纬度(在墨西哥的某个地方):

var geo = [19, -99]

我使用d3定义我的墨卡托投影

var projection = d3.geo.mercator();
projection(geo)
> [529.7418836818384, NaN]

这一点显然不在地图上.我到底在做什么错?谢谢!

Javascript has it's lat and long round the opposite way to the rest of the world, so what you've given D3 is a longditue of 19 and a latitude of -99. Obviously there is no latitude of -99 hence the NaN. Now if you just reverse your geo variable to

var geo = [-99, 19]

all should be good.

这篇关于D3墨卡托功能NaN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆