Google maps api 3 显示信息窗口谷歌标记外部点击咖啡脚本

Google maps api 3 显示信息窗口谷歌标记外部点击咖啡脚本,google-maps-api-3,coffeescript,Google Maps Api 3,Coffeescript,您好,我有一个与咖啡脚本和谷歌地图工作的外部链接问题 我尝试了很多解决方案,但我不明白为什么信息窗口不显示 jQuery(document).ready ($) -> if $('#map').length > 0 marker = google.maps.event.addDomListener(window, 'load', initialize); $('#map').after('<a href="#" id="open-marker">&

您好,我有一个与咖啡脚本和谷歌地图工作的外部链接问题

我尝试了很多解决方案,但我不明白为什么信息窗口不显示

jQuery(document).ready ($) ->

  if $('#map').length > 0
    marker = google.maps.event.addDomListener(window, 'load', initialize);
    $('#map').after('<a href="#"  id="open-marker"><span class="icon-icons_arrow-right"></span>open info window</a>');
    $('#open-marker').on 'click', ->
      google.maps.event.trigger marker, 'click'
      return

initialize = ->

  pos = undefined
  positionFound = false
  latlon = new google.maps.LatLng(50.5913444,8.7154506)
  #icon = new google.maps.MarkerImage(
  #  settings.marker_icon
  #)

  style = [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-100},{"lightness":40}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"saturation":-10},{"lightness":30}]},{"featureType":"landscape.man_made","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":10}]},{"featureType":"landscape.natural","elementType":"all","stylers":[{"visibility":"simplified"},{"saturation":-60},{"lightness":60}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"},{"saturation":-100},{"lightness":60}]}]

  mapOptions =
    zoom: 15,
    center: latlon,
    styles: style

  map = new google.maps.Map(document.getElementById('map'), mapOptions)
  contentString = "<h4>Info window</h4>"
  infowindow = new google.maps.InfoWindow(content: contentString)
  marker = new google.maps.Marker(
    position: latlon
    map: map
    title: ""
    icon: icon
  )

  google.maps.event.addListener marker, "click", ->
    infowindow.open map, marker
  return marker

所以我把你的咖啡脚本翻译成js并创建了。您的代码似乎正确,infowindow运行良好,除了变量
icon=new google.maps.MarkerImage(settings.marker\u icon)未定义设置的位置。。。当我注释掉图标行时,您的信息窗口工作得非常好。错误似乎是没有定义设置。

因此我将您的咖啡脚本翻译成js并创建了一个新的脚本。您的代码似乎正确,infowindow运行良好,除了变量
icon=new google.maps.MarkerImage(settings.marker\u icon)未定义设置的位置。。。当我注释掉图标行时,您的信息窗口工作得非常好。错误似乎是未定义设置。

我不知道您的设置。标记是什么。。。或者你的地图部门。。。请提供最低可行的代码(html,javascript),以便我可以复制您的错误。这是我得到的标记图标现在不相关我不知道你的设置。标记是。。。或者你的地图部门。。。请提供最低可行的代码(html,javascript),以便我可以复制您的错误。这是我得到的标记图标现在不相关我不知道你的设置。标记是。。。或者你的地图部门。。。请提供最低可行的代码(html,javascript),以便我可以复制您的错误。这就是我得到的标记图标现在无关紧要我试着用编辑来更深入地解释它我试着用编辑来更深入地解释它我试着用编辑来更深入地解释它我试着用编辑来更深入地解释它
    wp_enqueue_script( 'scripts', get_template_directory_uri() . '/js/app.js', array(), '20120206', true );

  $settings = array('marker_icon' => get_template_directory_uri().'/images/map-marker.svg');
  wp_localize_script('scripts', 'settings', $settings);