Search the Community
Showing results for tags 'google places'.
-
Waddup freaks? Thought I'd ask the more experienced people about Google places. I've been working on this very simple places search and I cannot get anything but a ZERO_RESULTS. It makes no sense to me at this point and I am offering up some code for debug if you'd be so kind. //BEGIN GOOGLE PLACES $( "#submit3" ).click(function(e) { e.preventDefault(); findPlaces(); $('#results').text("Triggah3!"); }); function findPlaces() { // prepare variables (filter) // var type = document.getElementById('gmap_type').value; // var radius = document.getElementById('gmap_radius').value; // var keyword = document.getElementById('gmap_keyword').value; var lat = document.getElementById("latitude").value; var lng = document.getElementById("longitude").value; // var lat = document.getElementById('lat').value; // var lng = document.getElementById('lng').value; var cur_location = new google.maps.LatLng(lat, lng); // prepare request to Places var request = { location: cur_location, radius: 50000, types: 'bank' }; // if (keyword) { // if used grab contents of search field // request.keyword = [keyword]; // } //console.log(request); // send request service = new google.maps.places.PlacesService(map); service.search(request, createMarkers); } // create markers (from 'findPlaces' function) function createMarkers(results, status) { // console.log(results); if (status == google.maps.places.PlacesServiceStatus.OK) { //ZERO_RESULTS // if we have found something - clear map (overlays) clearOverlays(); // and create new markers by search result for (var i = 0; i < results.length; i++) { createMarker(results[i]); } } else if (status == google.maps.places.PlacesServiceStatus.ZERO_RESULTS) { alert('Sorry, nothing is 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 to current marker google.maps.event.addListener(mark, 'click', function() { clearInfos(); infowindow.open(map,mark); }); infos.push(infowindow); } //END GOOGLE PLACES My script is loading just fine, in fact the map and some marker from my database load just fine upon their button click. Here is my link to the Google map API, key and library: <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&sensor=true&libraries=places&key=AIva&&DCtOkeKl&&xHLrC7eYzoLXzPrbdkkkYU&&2"></script>