Google maps Clojure中的Google API类出错
我在Clojure中调用Google map api时遇到此错误Google maps Clojure中的Google API类出错,google-maps,google-maps-api-3,clojure,clojure-java-interop,Google Maps,Google Maps Api 3,Clojure,Clojure Java Interop,我在Clojure中调用Google map api时遇到此错误 (defn calculate-distance-matrix "" [context] ;(def nearby-search-fucntion (do-nearby-search property-id context place-type) ) (let [r (. (. (. (DistanceMatrixApi/newRequest context) origin
(defn calculate-distance-matrix
""
[context]
;(def nearby-search-fucntion (do-nearby-search property-id context place-type) )
(let [r (. (. (. (DistanceMatrixApi/newRequest
context) origins (latlng {:lat 44.7415131 :lng 20.4957884}) )
destinations (latlng {:lat 44.71018809999999 :lng 20.50643759999999})) await)]
{:distance (-> r
.rows
first
.elements
first
.distance
.inMeters)
:duration (-> r
.rows
first
.elements
first
.distance
.inSeconds)})
)
错误消息:
IllegalArgumentException No matching method found: origins for class com.google.maps.DistanceMatrixApiRequest clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:80)
顺便说一下,这是Latlng功能:
(defn latlng
"Accepts a Latitiude and Longitude Key pairs"
[{:keys [lat lng]}]
(LatLng. lat lng))
Originates接受一个Java varargs,它是Clojure的一个数组。因此,您需要拨打的电话可能更像:
(. (. (. (DistanceMatrixApi/newRequest context) origins (into-array [(latlng {:lat 44.7415131 :lng 20.4957884})]))
where获取一个集合并根据此处数组的第一个元素的类型返回一个数组。顺便说一下,我将其添加到了project.clj[com.google.maps/google-maps-services 0.1.17]