2016-11-20 1 views
0

가장 가까운 농부 (포인트)를 특정 고객 (포인트)에게 보내려고합니다. 나는이 고객에게 버퍼를 만든 다음 버퍼 내부의 포인트를 얻을 잔디-내부를 사용하지만, 그것은 작동하지 않습니다와 나는이 오류를 얻을 :전단지에 버퍼 내부의 점 얻기

여기

Uncaught Error: A coordinate, feature, or point geometry is required

내 코드를

$.ajax({ 
     type:"POST", 
     url:"CustomerID_geojson.php", 
     data:{'Cust_Name': Cust_Name} , 
     dataType: 'json', 
     success: function (response) { 
      var unit = 'kilometers' 
      var buffered = turf.buffer(response, distance, unit) 

      $.ajax({ 
       type: "POST", 
       url: 'allfarmers_geojson.php', 
       dataType: 'json', 
       success: function (data) { 
        var ptsWithin = turf.inside(data, buffered); 
        geojsonLayer = L.geoJson(ptsWithin).addTo(mymap); 
        mymap.fitBounds(geojsonLayer.getBounds()); 
       } 
      }) 
      } 
     }) 
+0

코드를 디버깅 했습니까? 이 오류를 일으킨 라인은 무엇입니까? –

+0

@JeroenHeier 예,이 줄의 오류는 "var ptsWithin = turf.inside (data, buffered);" –

답변

0
당신은 오히려 대신 turf.within에 관심이있을 수

Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon.

Parameters

point (Feature<Point>) input point

polygon (Feature<(Polygon | MultiPolygon)>) input polygon or multipolygon

하십시오 turf.inside 문서의 모양과 서명이

.


원래 대답은 :

그 오류 메시지 중 하나를 당신의 response 또는 data 각각 turf.buffer 또는 turf.inside에 대한 유효한 인자는 아니다 뿌려줍니다. 변수의 내용을 출력하고 터프가 기대하는 바를 따르는 지 확인하십시오.

+0

버퍼의 첫 번째 부분은 잘 작동하고, 나는 응답과 데이터 모두에 대한 결과를 출력하려고 시도했다. 나는 [object] [object]를 얻었다. 바로 생각한다. –

+0

맞다면 스크립트는 불평하지 않을 것이다. 그럴거야? – ghybs

+0

다음은 data : Object {type : "FeatureCollection", features : Array [5]} 및 버퍼링 된 객체 {type : "Feature", geometry : Object, properties : Object}의 결과입니다. Turf가 기대하는 것입니까? –