Find your content:

Search form

You are here

Google Place Autocomplete and Custom Text Fields

 
Share

How can I implement Google Place Autocomplete at one of my custom text fields ?


Attribution to: David Renz

Possible Suggestion/Solution #1

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>

Attribution to: David Renz
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32153

My Block Status

My Block Content