How can I implement Google Place Autocomplete at one of my custom text fields ?
-
In the salesforce UI or in visualforce ?– Samuel De RyckeApr 8, 2014 at 10:24
-
Basically in the UI, but both would be good to know.– David RenzApr 8, 2014 at 10:26
1 Answer
I found a way to do it in Visualforce:
<apex:page id="page">
<script src="https://maps.googleapis.com/maps/api/js?language=de&sensor=false&libraries=places" type="text/javascript"></script>
<script type="text/javascript">
function initializeField() {
var input = document.getElementById('page:form:pb:pbs:field');
var autocomplete = new google.maps.places.Autocomplete(input);
}
google.maps.event.addDomListener(window, 'load', initializeField);
</script>
<apex:form id="form">
<apex:pageBlock id="pb">
<apex:pageBlockSection id="pbs">
<apex:inputText id="field"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
-
Is Google Places API not a paid for service? The comment about the API T&Cs here is quite interesting: github.com/benedwards44/sf-address-autocomplete Apr 18, 2017 at 15:21