1
我在轨道上制作了一个红宝石应用程序,这是我的一个咖啡脚本文件
我相信我的代码缩进了,但我仍然收到错误。
我标记了下面给出的注释错误。
请帮忙!Coffeescript不能正确转换
jQuery ->
today_date = new Date()
month = today_date.getMonth()
day = today_date.getDay()
pkpstyle= [
featureType: "landscape.natural"
elementType: "geometry"
stylers: [
lightness: -29
,
hue: "#ffee00"
,
saturation: 54
]
,
featureType: "poi.park"
stylers: [
lightness: -35
,
hue: "#005eff"
]
,
featureType: "road.arterial"
,
featureType: "road.arterial"
stylers: [ lightness: 45 ]
]
tempDay = 4
//I get an error here saying Uncaught TypeError: undefined is not a function
today_latlng = getLatlng(stops[tempDay])
markericon = new google.maps.MarkerImage("/assets/cycling.png")
myOptions =
center: today_latlng
zoom: 12
minZoom: 4
styles: pkpstyle
mapTypeId: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions)
for i of stops
latlng = getLatlng(stops[i].latlng)
marker = new google.maps.Marker(
map: map
icon: markericon
position: latlng
)
getLatlng = (loc) ->
loc_split = loc.split(", ")
lat = loc_split[0]
lng = loc_split[1]
new google.maps.LatLng(lat, lng)
getLatLong在那里评估为undefined。有什么问题? (Coffeescript是否允许像这样的前向声明?JavaScript中的FunctionStatements *而不是*“var f = func”语句允许前向声明.JS最终是什么?我想象成一个'var' ...因此' undefined'。) – 2012-04-25 23:20:36
您是否将此代码从Javascript转换为CoffeeScript? – Jonathan 2012-04-25 23:22:27