Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrisgrim's avatar

Using autocomplete and RE-Searching address with only postal_code

Hi, I am struggling with a specific problem. For each event a user uploads I get the address using google autocomplete. I want to set it up so users can say don't show my specific address and instead it will use the latitude and longitude of the city or zip code returned from their address.

        mounted() {
            this.autocomplete = new google.maps.places.Autocomplete(
                (this.$refs.autocomplete),
                {types: ['geocode']}
            );
            this.autocomplete.addListener('place_changed', this.setPlace);
        },

I tried adding this to the mounted

            this.incognito = new google.maps.places.Autocomplete(
                (this.hiddenSearch),
                {types: ['geocode']}
            );

and then when I submit

onIncognitoSubmit() {
                this.hiddenSearch = this.location.postal_code ? this.location.postal_code : this.location.city;
                let place = this.incognito.getPlace();

but I get an undefined and when the page first loads I get the error InvalidValueError: not an instance of HTMLInputElement. Thanks for any help!

0 likes
4 replies
chrisgrim's avatar

Ok, The easier fix is to just delete some of the detailed lat and lng. So instead of 38.2334443 its 38.23

davidifranco's avatar

So if a user says dont show my specific address you want the to save only the coordinates of the city? Or you want to save the coordinates of the address but only display the city coordinates?

chrisgrim's avatar

Only save the coordinates of the city would work!

Please or to participate in this conversation.