javascript - turf.js 返回无效坐标
问题描述
此代码是一个程序的一部分,该程序接收用户在搜索栏中输入的地址并尝试在地图上找到它们。这是该网站的链接。
createSQL: function() {
SearchableMapLib.currentPinpoint = [results[0].geometry.location.lat(), results[0].geometry.location.lng()];
var address = $("#search-address").val();
SearchableMapLib.currentResults = JSON.parse(JSON.stringify(SearchableMapLib.geojsonData));
if(SearchableMapLib.currentPinpoint != null && address != '') {
var point = turf.point([SearchableMapLib.currentPinpoint[1], SearchableMapLib.currentPinpoint[0]]);
var buffered = turf.buffer(point, SearchableMapLib.radius, {units: 'meters'});
///it breaks here at turf.pointsWithinPolygon
SearchableMapLib.currentResults = turf.pointsWithinPolygon(SearchableMapLib.currentResults, buffered);
if (SearchableMapLib.debug) {
console.log('found points within')
console.log(SearchableMapLib.currentResults);
}
但是,它告诉我“未捕获的错误:没有有效的坐标”。
我很确定坐标是有效的。例如,当我输入console.log('point: ' + SearchableMapLib.currentPinpoint[1] + ' ' + SearchableMapLib.currentPinpoint[0]);
它返回point: -83.6235566 42.24362170000001
为什么会发生此错误?
(我是 javascript 新手,没有编写此代码(它基于模板),如果其中任何一个没有意义,请告诉我。)
解决方案
也许纬度和经度是相反的?一个在南极洲,另一个在底特律附近。
推荐阅读
- rust - 如何从结果中取出 T
>>? - javascript - 如何在 JavaScript 中返回使用 promise 获取的文件?
- python - 如果条件满足,识别并单击无序列表中的按钮
- python - python上传大文件-错误:消息413请求实体太大-忽略100-继续
- python - (Discord.py) 我的程序无法为我的 sqlite3 文件添加价值
- android - 如何使用 Volley 发送以通过 post 检索它们以发出 PHP 请求
- reactjs - 如何从 Promise.all 中的多个端点获取多个数据?
- excel - 无法将计算字段添加到数据透视表
- postgresql - PostgreSQL 幂等Policy row level se
- javascript - vuex中未知的突变类型