Your address will show here +12 34 56 78

Home Forums WP RESIDENCE – Real Estate WordPress Theme FORUM Change the auto-complete address rules for different Fields – starting v 1.07

This topic contains 3 replies, has 4 voices, and was last updated by  mitchoo 2 years, 3 months ago.

  • Author
    Posts
  • #100854

    Anna
    Keymaster

    Google maps address details are assigned to auto-complete in a JS file.

    Documentation – 

    Google documentation moved to https://developers.google.com/maps/articles/geocodestrat

    and for the types used

    https://developers.google.com/maps/documentation/geocoding/

    If you are confident to modify the fields, you can edit the assignment of the fields in FILE:

    js/google_js/google_maps_submit.js

    Default code:

    function fillInAddress(place) {
            $('#property_area').val('');
            $('#property_zip').val('');
            $('#property_county').val('');
            $('#property_city_submit').val('');
            
            for (var i = 0; i < place.address_components.length; i++) {
              var addressType = place.address_components[i].types[0];
           
                var temp='';
                var val = place.address_components[i][componentForm[addressType]];
               
          
                    
                if(addressType=== 'street_number' || addressType=== 'route'){
                  //  document.getElementById('property_address').value =  document.getElementById('property_address').value +', '+ val;
                }else if(addressType=== 'neighborhood'){
                     $('#property_area').val(val);
                }else if(addressType=== 'postal_code_prefix'){
                   // temp = $('#property_zip').val();
                    $('#property_zip').val(val);
                }else if(addressType=== 'postal_code'){
                   // temp = $('#property_zip').val();
                    $('#property_zip').val(val);
                }else if(addressType=== 'administrative_area_level_2'){
                    $('#property_county').val(val);
                }else if(addressType=== 'administrative_area_level_1'){
                    $('#property_county').val(val);
                }else if(addressType=== 'locality'){
                    $('#property_city_submit').val(val);
                }else if(addressType=== 'country'){
                    $('#property_country').val(val);
                }else{
                   
                }
                
              
            }
            
        }
    • This topic was modified 2 years, 10 months ago by  Anna.
    • This topic was modified 2 years, 6 months ago by  Anna.
    • This topic was modified 2 years, 1 month ago by  Anna.
  • #103769

    lexuspro
    Participant

    Sorry, Anna!
    This code is designed to address are automatically clipped to the street?
    Could you write this code again in the tag /CODE

  • #104332

    Greatone
    Participant

    https://www.google.com/maps/place/Peninsula+Rd,+Kelvin+Heights,+Queenstown+9300,+New+Zealand/@-45.0354441,168.7038649,17z/data=!4m2!3m1!1s0xa9d51e030d9eb623:0x5376ee763169f01e

    Can you tell me what type is use for kelvin heights?

    like peninsula = street address

    queenstown = city address

    9300 = postal code

    New Nealand = country

    kelvin heights = ?

    because i used neighbourhood, sublocality, and so on but nothing get the kelvin heights from address, though everything else is getting like country, locality/city, postal code, and so on.

  • #110111

    mitchoo
    Participant

    Google documentation moved to https://developers.google.com/maps/articles/geocodestrat

    and for the types used

    https://developers.google.com/maps/documentation/geocoding/

    • This reply was modified 2 years, 3 months ago by  mitchoo.

You must be logged in to reply to this topic.