javascript - No HTML on InfoWindow when using setContent -
i have been using flask-googlemaps extension from: https://github.com/nikulesko/flask-googlemaps
i trying insert html in infowindows these not show (the tags show plaintext). how achieve this? thought passing string html tags on render html on infowindow not work. how content of infowindow set:
var infowindow = new google.maps.infowindow({ content: "loading..." }); {% marker in gmap.markers %} var marker_{{loop.counter}} = new google.maps.marker({ position: new google.maps.latlng({{marker.0}}, {{marker.1}}), map: {{gmap.varname}}, title: '{{marker.2}}', icon: '{{marker.3}}', }); google.maps.event.addlistener(marker_{{loop.counter}}, 'click', function() { infowindow.setcontent('{{marker.4}}'); infowindow.open({{gmap.varname}}, this); }); {% endfor %} any ideas? markers list containing tuples of marker has (latitude, longitude, title, icon, info). marker.4 string.
edit: have tried like
infowindow.setcontent("some text html...") and works fine showing html when do
infowindow.setcontent("{{marker.4}}") the html not show up. have tried setting variable (just before line addlistener called):
var contentstr = '{{marker.4}}'; then:
infowindow.setcontent(contentstr); however, doesnt work either. dont understand difference between passing jinja variables , plain js. how achieve functionality want using python string/jinja variable?
in jinja2, inside for loop don't have loop.counter loop.index shows current iteration of loop (starting 1). , loop.index0 thing starting 0.
also should put between quotes jinja variables in javascript code, ex:
position: new google.maps.latlng("{{marker.0}}", "{{marker.1}}")
Comments
Post a Comment