1
나는 왜 모두의 끝에서 클래스커피 스크립트 바인딩 변수
class window.MapHandler
map = null
userLocationMarker = null
makeMap: (location) ->
myOptions =
zoom: 14
center: location
mapTypeId: google.maps.MapTypeId.ROADMAP
@map = new google.maps.Map(document.getElementById("map_canvas"), myOptions)
placeMarker: (location, icon_path) ->
if icon_path
markerImage = new google.maps.MarkerImage(icon_path, null, null, null, new google.maps.Size(25, 25))
else
markerImage = null
marker = new google.maps.Marker(
position: location
map: @map
icon: markerImage)
defineUserLocation:() ->
if navigator.geolocation
navigator.geolocation.getCurrentPosition(
(position) =>
pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
infowindow = new google.maps.InfoWindow(
map: @map
position: pos
content: 'Если это не ваше местоположение - передвиньте маркер'
)
@map.setCenter(pos)
@userLocationMarker = @placeMarker(pos, null)
)
alert @userLocationMarker.getPosition()
이 내가 가지고 중심으로지도와 메이커이 시점에서, 그러나 @userLocationMarker입니다 정의되지에는 getPosition 메소드 호출 오류?
그러나 나는 userLocationMarker = null을 클래스 최상위에 가지고 있습니다. – rkotov93
@ koshak1993 : 아, userLocationMarker : null이어야합니다. – thejh
이해가 안됩니다. 왜, (위치) 함수가 변수 맵을 보지만, userLocationMarker가 보이지 않는다. – rkotov93