function getInsertionLatLng(latlngs, latlng) { // Find the nearest points on the line…
- User
function getInsertionLatLng(latlngs, latlng) { // Find the nearest points on the line console.log(latlngs); console.log(latlng); try { var closestPoint = L.GeometryUtil.closest(map, latlngs, latlng); } catch (error) { console.error(error);
code} var closestLatLng = [closestPoint.lat, closestPoint.lng]; console.log("Close Point : "+closestLatLng); var index = latlngs.findIndex((ll) => ll.lat == closestPoint.lat && ll.lng == closestPoint.lng); alert(index); // Calculate the midpoint between the nearest points var nextIndex = index + 1 < latlngs.length ? index + 1 : index; try { var midpoint = L.latLng( (latlngs[index].lat + latlngs[nextIndex].lat) / 2, (latlngs[index].lng + latlngs[nextIndex].lng) / 2 ); } catch (error) { console.log("the error is : "+error); } alert("here"); return { midpoint, index: nextIndex }; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.