Show info window google marker external click with coffeescript -
hi there i've problem getting external link work coffeescript , google maps.
i've tried many solutions can't figure out why info window isn't showing
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
the browser shows no error. settings marker icon added via wordpress localize script -> icons shows , marker click function works also.
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);
so i've translated coffeescript js , created jsfiddle project. code seems right , infowindow works great except variable icon = new google.maps.markerimage(settings.marker_icon);
settings not defined... infowindow works fine when commented out icon line. error seems settings not defined.
Comments
Post a Comment