Google Places API - Get address, phone number etc -
i trying further information places showing on map, such place address, phone number etc. can see code here:
http://jsfiddle.net/aboother/4q3jcg1s/
i have done 'console_log(place)' below:
function createmarker(place) { var placeloc = place.geometry.location; var marker = new google.maps.marker({ map: map, position: place.geometry.location }); console.log(place); var request = { reference: place.reference }; service.getdetails(request, function(details, status) { google.maps.event.addlistener(marker, 'click', function() { console.log(place); infowindow.setcontent(place.name + "<br />" + place.vicinity); infowindow.open(map, this); }); }); }
but can't see address or phone number in object though know can information. can see 'vicinity', 'name' , other basic information. can help?
well used service: service.nearbysearch()
search nearby based on criteria. there following service: service.getdetails()
perspective details. not sure understanding service uses placeid match , details pertaining location.
in regards code, instead of directly creating marker each place, pass getdetails() service , create marker. logged place , details there, use data needs.
below modified code:
function callback(results, status) { if(status == google.maps.places.placesservicestatus.ok) { for(var = 0; < results.length; i++) { service.getdetails(results[i], function(place, status) { if (status == google.maps.places.placesservicestatus.ok) { var marker = new google.maps.marker({ map: map, position: place.geometry.location }); console.log(place); google.maps.event.addlistener(marker, 'click', function() { infowindow.setcontent(place.name); infowindow.open(map, this); }); } }); } } }
here fiddle: use whichever console used expand each location , see data, phone numbers, review: http://jsfiddle.net/r61tqtxw/1/
Comments
Post a Comment