Home › Forums › Backend Issues (wp-admin) › Extend Google Maps field with Places › Reply To: Extend Google Maps field with Places
Hi @eberger3,
No I didn’t!
But what worked for me was using the location data. So do a search and then get the all the place details, here is my code, enjoy.
Jonas
$('.hotspots-details').each(function(){
var location = $(this).attr('data-location');
if(location){
var request = {
query: location
};
var service = new google.maps.places.PlacesService(map);
service.textSearch(request, callbacksingle);
}
});
and then something like:
function callbacksingle(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: results[0].place_id
}, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
//console.log(place);
var output;
output = '';
//address
if(place.adr_address){
output += '<h3>Adres</h3>';
output += place.name+'<br>';
address = place.adr_address.split(', ');
for(var i=0; i<address.length; i++){
output += address[i]+'<br>';
}
}
//phonenumber
if(place.formatted_phone_number){
output += '<a href="tel:'+place.formatted_phone_number+'">'+place.formatted_phone_number+'</a><br>';
}
//website
if(place.website){
output += '<a href="'+place.website+'">'+place.website+'</a><br>';
}
output += '';
//output everything
$('.google-data').append(output);
}
});
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.