【发布时间】:2012-06-10 03:14:36
【问题描述】:
我正在使用 CoffeeScript、Backbone.js 和 Google Maps API 对 lat / lng 进行反向地理编码
我有这个功能
country: (origin, callback) ->
@geocoder = new google.maps.Geocoder
@geocoder.geocode(
'latLng': origin,
(results, status) =>
if status is google.maps.GeocoderStatus.OK
callback(result[6])
else alert("Geocode was not successful for the following reason: " + status);
)
当我调用它时,我使用:
@country(origin, (data) =>
console.log(data.formatted_address)
)
顺便说一句:
origin = new google.maps.LatLng(origin_lat, origin_lng)
这不起作用,它甚至似乎都没有调用它。我在(data) 下有回调函数,但无法让它工作...
谢谢
【问题讨论】:
-
您是否尝试删除使用 origin 的关键部分(冒号前面的内容),即不将其作为键值对传递,而只是将 origin 作为对象传递?跨度>