なので、Google Maps API と CoffeeScript の両方を扱うのは初めてです。マーカー クリックでポップアップする infoWindow がありますが、それらは誰かが別のマーカーをクリックして代わりに別の infoWindow を表示したときにのみ削除され、それ以外の場合は閉じません。ユーザーがクリックしてポップアップ ボックスから離れたときにポップアップ ボックスを閉じる必要があるだけです。使用しているコードは次のとおりです (少し長すぎる場合は申し訳ありません。正確な呼び出しがどこにあるのかわかりません)。
@infoWindow = new google.maps.InfoWindow unless @infoWindow?
@infoWindow.close()
places = if @options.places? and @options.places.length > 0 then @options.places else null
if places?
# add pins
@add_pins(places)
# fit bounds
if @options.googleMap.setBounds == true
@set_bounds(places)
# ie8 hack
ie_8_map()
# results
if @options.resultType == 'floating'
$(".places-map .overlay").show()
#######
add_pins: (places) ->
@pins = {}
if @markers
for marker in @markers
marker.setMap null
for place, i in places
@pins[place.id] = '/assets/pins/'+ String.fromCharCode('A'.charCodeAt()+i)+'.png'
project_pin = new google.maps.MarkerImage '/assets/pins/'+ String.fromCharCode('A'.charCodeAt()+i)+'.png', new google.maps.Size(40, 63), new google.maps.Point(0,0), new google.maps.Point(20, 63)
project_pin_shadow = new google.maps.MarkerImage '/assets/pin-shadow.png', new google.maps.Size(74, 63), new google.maps.Point(0,0), new google.maps.Point(22, 63)
marker = new google.maps.Marker map: @googleMap, position: @_latLng(place), icon: project_pin, shadow: project_pin_shadow
@markers.push marker
# Adding the pop-up info window
if place.name
google.maps.event.addListener marker, 'click', @clickMapMarker.bind(this, place, marker)
# Add pin pictures
for k,v of @pins
pinImg = $(".place-result ." + k + "_place_pin")
pinImg.parent(".place_pins_popup_img").show()
pinImg.attr("src", v)
#######
clickMapMarker: (place, marker) ->
@infoWindow.close()
if @options.resultType == 'leftbar'
if place.result_html
@infoWindow.setContent place.result_html
else
pop = $('<div class="place-result"></div>').html($('#res_' + place.id).clone().attr("id":"cln_"+place.id))
pop.find('.place_pins_popup_img').remove()
#pop.find('.place_pins_popup_img').remove()
@infoWindow.setContent pop.html()
else
@infoWindow.setContent JST["templates/places_map_listings"](places: [place])
@infoWindow.open(@googleMap, marker)