0
다음 코드는지도를 렌더링하지만 click 이벤트에서 콜백이 실행되지 않습니다. 어떤 아이디어?Google지도 API - 클릭 이벤트가 작동하지 않습니다.
google.maps.visualRefresh = true
url = 'http://localhost:3000/closeby'
getCloseBy = (pos) ->
$.post url, {'center': pos}
initialize = ->
mapOptions =
zoom: 15
mapTypeId: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map document.getElementById('map-canvas'), mapOptions
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
map.setCenter pos
, ->
handleNoGeolocation true
else
handleNoGeolocation false
handleNoGeolocation = (errorFlag) ->
if errorFlag
content = 'Geolocation failed'
else
content = 'Your browser does not support Geolocation'
options =
map: map
position: new google.maps.LatLng 60, 105
content: content
infowindow = new google.maps.InfoWindow options
map.setCenter options.position
placeMarker = (location) ->
marker = new google.maps.Marker
position: location
map: map
google.maps.event.addListener map, 'click', (event)->
placeMarker event.latLng
google.maps.event.addDomListener window, 'load', initialize
내가 코드를 업데이트 및 장소 표시에 대한 인수로 맵을 통과하지만, 내가 클릭하는 곳에 마커가 표시되지 않습니다. – tldr
답변이 업데이트되었습니다. 보시다시피 저는 CoffeeScript를 사용하지 않습니다. 어쩌면 방법을 이동하는 것은 갈 길입니다. – michaelrp
코드를 업데이트하고 초기화 코드를 넣어 두었습니다. 여전히 작동하지 않습니다. – tldr