javascript - Suggestion box only displays , , -


i making mashup website involves map, , search textbox in javascript. title says, no matter inputted search box, 2 commas appear in suggestion box , when suggestion clicked on, turn map gray , unusable. whats problem? javascript file, function located in configure function

// google map var map;  // markers map var markers = [];  // info window var info = new google.maps.infowindow();  // execute when dom loaded $(function() {  // styles map // https://developers.google.com/maps/documentation/javascript/styling var styles = [      // hide google's labels     {         featuretype: "all",         elementtype: "labels",         stylers: [             {visibility: "off"}         ]     },      // hide roads     {         featuretype: "road",         elementtype: "geometry",         stylers: [             {visibility: "off"}         ]     }  ];  // options map // https://developers.google.com/maps/documentation/javascript/reference#mapoptions var options = {     center: {lat: 35.7640, lng: -78.7786}, // cary, north carolina     disabledefaultui: true,     maptypeid: google.maps.maptypeid.roadmap,     maxzoom: 14,     pancontrol: true,     styles: styles,     zoom: 13,     zoomcontrol: true };  // dom node in map instantiated var canvas = $("#map-canvas").get(0);  // instantiate map map = new google.maps.map(canvas, options);  // configure ui once google map idle (i.e., loaded) google.maps.event.addlisteneronce(map, "idle", configure);  });  /**  * adds marker place map.  */ function addmarker(place) { var url = "/search?q=" + place; $.getjson(url, function(data){     var location = data.latitude + data.longitude;     mark = new google.maps.marker(location, map);     markers[0] = mark; });  }  /**  * configures application.  */ function configure() { // update ui after map has been dragged google.maps.event.addlistener(map, "dragend", function() {      // if info window isn't open     // http://stackoverflow.com/a/12410385     if (!info.getmap || !info.getmap())     {         update();     } });  // update ui after zoom level changes google.maps.event.addlistener(map, "zoom_changed", function() {     update(); });  // configure typeahead $("#q").typeahead({     highlight: false,     minlength: 1 }, {     display: function(suggestion) { return null; },     limit: 10,     source: search,     templates: {         suggestion: handlebars.compile(             "<div>" +             "<p>{{ place_name }}, {{ admin_name1 }}, {{ postal_code }}</p>" +             "</div>"         )     } });  // re-center map after place selected drop-down $("#q").on("typeahead:selected", function(eventobject, suggestion, name) {      // set map's center     map.setcenter({lat: parsefloat(suggestion.latitude), lng: parsefloat(suggestion.longitude)});      // update ui     update(); });  // hide info window when text box has focus $("#q").focus(function(eventdata) {     info.close(); });  // re-enable ctrl- , right-clicking (and inspect element) on google map // https://chrome.google.com/webstore/detail/allow-right-click/hompjdfbfmmmgflfjdlnkohcplmboaeo?hl=en document.addeventlistener("contextmenu", function(event) {     event.returnvalue = true;      event.stoppropagation && event.stoppropagation();      event.cancelbubble && event.cancelbubble(); }, true);  // update ui update();  // give focus text box $("#q").focus(); }  /**  * removes markers map.  */ function removemarkers() { // todo }  /**  * searches database typeahead's suggestions.  */ function search(query, syncresults, asyncresults) { // places matching query (asynchronously) var parameters = {     q: query }; $.getjson(flask.url_for("search"), parameters) .done(function(data, textstatus, jqxhr) {      // call typeahead's callback search results (i.e., places)     asyncresults(data); }) .fail(function(jqxhr, textstatus, errorthrown) {      // log error browser's console     console.log(errorthrown.tostring());      // call typeahead's callback no results     asyncresults([]); }); }  /**  * shows info window @ marker content.  */ function showinfo(marker, content) { // start div var div = "<div id='info'>"; if (typeof(content) == "undefined") {     // http://www.ajaxload.info/     div += "<img alt='loading' src='/static/ajax-loader.gif'/>"; } else {     div += content; }  // end div div += "</div>";  // set info window's content info.setcontent(div);  // open info window (if not open) info.open(map, marker); }  /**  * updates ui's markers.  */ function update()  { // map's bounds var bounds = map.getbounds(); var ne = bounds.getnortheast(); var sw = bounds.getsouthwest();  // places within bounds (asynchronously) var parameters = {     ne: ne.lat() + "," + ne.lng(),     q: $("#q").val(),     sw: sw.lat() + "," + sw.lng() }; $.getjson(flask.url_for("update"), parameters) .done(function(data, textstatus, jqxhr) {     // remove old markers map    removemarkers();     // add new markers map    (var = 0; < data.length; i++)    {        addmarker(data[i]);    } }) .fail(function(jqxhr, textstatus, errorthrown) {      // log error browser's console     console.log(errorthrown.tostring()); }); }; 

nvm, figured out in application.py, should have put jsonify(value) instead of jsonify([value]).


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -