javascript - Google Places and ZERO_RESULTS -
i've been working on simple google places search , cannot zero_results. makes no sense me @ point map working , displays markers database within separate ajax function. i've logged objects , variables , seem fine.
why success callback go right else statement zero_results?
$( "#submit3" ).click(function(e) { e.preventdefault(); findplaces(); $('#results').text("triggah3!"); }); function findplaces() { var lat = document.getelementbyid("latitude").value; var lng = document.getelementbyid("longitude").value; var cur_location = new google.maps.latlng(lat, lng); // prepare request places var request = { location: cur_location, radius: 50000, types: 'bank' }; // send request service = new google.maps.places.placesservice(map); service.search(request, createmarkers); } // create markers (from 'findplaces' function) function createmarkers(results, status) { if (status == google.maps.places.placesservicestatus.ok) { //zero_results // if have found - clear map (overlays) clearoverlays(); // , create new markers search result (var = 0; < results.length; i++) { createmarker(results[i]); } } else if (status == google.maps.places.placesservicestatus.zero_results) { alert('sorry, nothing found'); } } // create single marker function function createmarker(obj) { // prepare new marker object var mark = new google.maps.marker({ position: obj.geometry.location, map: map, title: obj.name }); markers.push(mark); // prepare info window var infowindow = new google.maps.infowindow({ content: '<img src="' + obj.icon + '" /><font style="color:#000;">' + obj.name + '<br />rating: ' + obj.rating + '<br />vicinity: ' + obj.vicinity + '</font>' }); // add event handler current marker google.maps.event.addlistener(mark, 'click', function() { clearinfos(); infowindow.open(map,mark); }); infos.push(infowindow); }
types
expected array.
use:
types: ['bank']
Comments
Post a Comment