这段代码是一个程序的一部分,它接受用户在搜索栏中输入的地址,并试图在地图上找到它们。这是一个link to the site.
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的新手,并没有编写这段代码(它是基于template的),如果有任何不合理的地方,请告诉我。)
发布于 2021-02-26 05:43:09
也许纬度和孤度是颠倒的?一个在南极洲,另一个在底特律附近。
https://stackoverflow.com/questions/66376830
复制相似问题